I have a date validation function that I want to stay at the object I am
validating if there is a Validation error, but it always goes to the next
object.
The javascript:
function ValidateForm(me){
var dt=me
if (isDate(dt.value)==false){
dt.focus()
return false
}
return true
}
I have a form for inputting data to a database. One of the fields in the form takes a unique identifier which forms the primary key in the db table. I am using Ajax to check that the data entered into this field by the user doesn't already exist in the db - this is working perfectly!
When the user entered-data matches a record in the database table, they are warned of this in an alert window, and the data they entered is deleted, and the focus then automatically goes to the next field. What I want to do is return the focus to the same field. I'm using the focus() method but it doesn't work for me. Code:
I am opening a new window using window.open. I need the new window to open on top of the parent everytime. I cannot use onBlur b/c the user will need to click back to the parent for information. I just need it to open on top everytime. I am using this line in the body <body onload="window.focus()" bgColor="#0077d6" ms_positioning="GridLayout">
The window.focus doesn't work everytime. I can open it and it may work. I will completely close the app, start it again and it will not work, but the next time it might. It is inconsistent. How do I get it to not give focus back to the parent after it opens? How can I get the parent to relinquish focus?
I have a requirement to handle dates by using three fields, a (year) text field and two (month and day) selects. I fill the selects using jQuery, which works beautifully. However, I have an onblur handler for the year field that handles filling the month select and an onblur handler for the month select that handles filling the day select. Part of this is to get the right number of days for a month (and for leap years), but part of it is also to force users to enter the data in order so that I can process it correctly.
However, I check in both the onblur handler of the year text box and the onblur handler of the month select whether or not the year value is entered (since if it isn't, there's no point in continuing to the day field). If there is no year value, I call
$year.focus();
and exit the handler.
Unfortunately, the focus when all this returns is still on the month select. Adding "event.preventDefault()" and "event.stopPropogation()" within the handler have no effect.
I have a feeling that there's something very subtle going on that I'm missing. Among the points I have realized is that calling $year.focus() in the year onblur handler may activate the month onblur handler (since the month is the next input, I assume it gets focus when the year is blurred). This should not have any effect, since both handlers check for the year value just in case - but I wanted to note it in passing.
I am working in a third party application which has a hookinto their window.onload() function.(it calls my fnCustomOnload. In my fnCustomOnload() function I have tried to bind a focusout event on a particular input and have it call a function callled fnGetRestriction(). The function fnGetRestriction()actually works without errors, I have forced it with the grabfocus.focus (lines 2 and 3)but it is called not being called anytime other than once at the beginning when it is force by lines 2 and 3.. The line that performs the alert() (line 4)works properly all the time. What is wrong with line 5?
This JS code is on RoR+ImgMap site.I've tweak several portion of ImgMap, specifically around line 2205 of the file imgmap.js by adding code.so that when the user draws a shape, the focus will be set to the respective href field, instead of the default behavior - adding new row(imgmap form).
I'm using thickbox for getting a popup at my screen where the user can write info into inputfields.Only I want that the first inputfield is selected/focus.I have use the following codes but nothing is working.
I'm trying to build a data navigation utility that will allow a central "map" page to control a number of tab pages that are loading individual pages from a large set of HTML. All are local file://localhost/, with localhost popups enabled. (for dev/testing all popups are enabled since firebug 1.3.3 has problems loading localhost .js code) preference to "raise and lower windows" has been enabled I am using firefox 3.0.8 on FreeBSD 6.4
Anyway, I can't get window.focus() and blur() to work between cooperating tab/windows who know each other's names.
Here following are two cooperating mirror tab pages that i'm trying to get working. Have tried a number of combinations of the focus() and blur() calls. Have tried with/without messaging. Messaging works fine.
I have noticed that the calling tab seems to unload/reload as a result of the click event. This still allows the message to get through OK, but I guess the reload could be taking the focus again.
An annoying alert() dialog could of course get focus to the message receiver, but it requires another click to get it out of the way.
The concept of these focus() and blur() calls is so simple, and I've searched all over the web for examples, but nothing seems applicable.
Have also seen that this may be a bug in Firefox.
======== code for "mirror" pages "focus1" and "focus2" follows:
I am trying to throw in some client-side validation to my php web form. My problem is that only one field is actually getting validated. Here is the code:
Form: onSubmit="return checkForm(this);"
script: function checkForm(form) { var firstname = document.getElementById("wpFirstName").value; var lastname = document.getElementById("wpLastName").value;
The if statement evaluating the last name field is the only statement that evaluates to true. It seems the first statment is bypassed. Any ideas? PS. the element with the id lastNameError/firstNameError is in a div tag.
I'm currently making a web application which needs to be fully compatible with iPad. The functions I've implemented so far work perfectly on Firefox, Internet Explorer and other browsers. However, the iPad itself responds a bit different. After a certain action, I want to put focus on a textfield with the help of Javascript. Again, this works perfectly with the normal browser, the iPad browser however seems to be blocking the focus. The reason I'm not posting any code is because it's basically irrelevant. All I do is:
Is there a reason why setting focus to a textbox input, also gives focus to a submit button on the page, to where if you click enter in the text box, the submit button will be clicked.
The default behaviour of focus() method is displaying the cursor at start of the char(In FF focusOffset is 0(zero) and anchorOffset is 0(zero)). I need to display the focus at end of char after calling focus() method.
I think the problem is cause by my lack of understanding of how the browser (firefox 3.6.3) handles focus.A simplified version of my problem is:I've defined the function
function two_focus() { document.getElementById("two").blur();
Is there a way to set the focus on a form field without using focus()? I use ajax to build the form and if I try to set the focus using focus() an error is generate because of the form hasn't been built by ajax. So, it would be nice if I could set the focus() as I built the form.
Is there any way to tell the difference between when this anchor is focused by a user (perhaps by tabbing to it) as opposed to when I programatically do it via anchor_node.focus()?
When I validate a form on submission I use the javascript focus function to scroll the page to the location of the form error e.g.
document.[Form Name].[Field Name].focus();
If you happened to have the page scrolled above where the error field is then the page will scroll so that the error field is at the very top of the window. If you happened to have the page scrolled below where the error field is then the page will scroll so that the error field is at the very bottom of the window. Neither of these is very desirable. Any way to get the error field to the middle of the window?
e.g. in javascript after the focus statement, can one test the location of the error field and then either add half a windows worth of pixels to it if it is at the top of the screen or subtract half a windows worth of pixels to it if it is at the bottom of the screen?
If in the textarea (textarea3), the value is not "abc", and the user uses "Tab" to go to the next textarea (textarea4), it will alert an error message...and the focus will return to the textarea (textarea3) again...
It works in Internet Explorer, however in firefox it does not work? Anyway have any ideas why & how? Code:
If I use the following construct in the frame "main" for a link to an extern site:
<A HREF="http://www.any.xy" TARGET="extern">
the Browser is creating the window "extern", loading the page www.any.xy an setting the focus to "extern". But when I go return to "main" without closing "extern", a click to an other link (e.g. www.2nd_any.xy) on "main" does not setting the focus to "extern".
For setting the focus to "extern" in the second case, I have used the following construct:
<A HREF="http://www.any.xy" TARGET="extern" onClick="setTimeout('extern=window.open('','extern');fr emd.focus();',500);"> an example</A>
This construct has worked very well for a few years, but since about one year, the sesult was the same as using <A HREF="http://www.any.xy" TARGET="extern">
In this year, I have changed: win 95 --> win 2000 modem 56k --> DSL Netscape 4.5 --> Netscape 7.1
Can anybody tell me a possibility setting the focus to "extern" in the second case? Is the changing of my configuration the reason, that the construct has failed?
Neglecting the annoyance factor for a moment, is it possible to keep one browser window at the screen forefront (in front of all other browser windows) but still be able to interact with a window directly beneath it? How would this be pulled off in JS?
I encountered some strange behaviour when using focus()
I use a form with several input-fields. A user can enter stuff. After entering I want to check the value, i.e. that a number is only a number etc. I therefore started editing a Javascript. For test purposes it only popup a message and sets the focus. In fact this is what I want to do, but the scipt isn't it doing right.
I'm trying to do default focus on checkbox,its work fine but the problem is that the user cannot know where is the focus (there isn't visual sign and on the other hand if you press on the tab button there is a visual sign).
I have a page that has 3 different iframes in it. The bottom iFrame continually gets updated as the user adds different images to it through the interface, and once the user clicks one of the images, I change the style of the image to put a border around it. The problem is, once I set off this function to put a border around the clicked image, the iFrame resets itself. So, if I've scrolled over to the right a bit and clicked on a pic, the frame resets itself all the way to the left, so the user would have to scroll back over to see the pic they just clicked.
I've tried doing an onFocus in the function that adds the style, and it's not working.