This is a generic function so it uses 'this' - onBlur="chkMonthDob(this);"
The function then checks it and puts the focus back on 'this' if it is wrong. This all works fine in IE but in Firefox it does not put the focus back.
Using the Firefox getaround :- setTimeout("document.orgsp.d1_org_dob_mth.focus()", 1); works, however, when it is called with 'this' as a parameter you don't know what the field is to be focussed on, so I had hoped that putting :-
var focusField = myField.id; setTimeout("document.getElementById(focusField).focus()", 1);
would work - but Firefox say focusField is undefined.
I have an AJAX application for a form that has 4 columns and 170 rows. It uses an onblur call to update a database each time you move out of a cell. This works fine.
Client wanted to validate for a number so I added a function to check for this and an alert call if the numer check failed. This works fine.
However, dismissing the alert results in the focus moving to the next cell rather than returning to the invalid cell. Big problem. I have been successful in coding focus to go to any other cell in the table except the one with the errror. Code:
I'm having a problem returning focus back to an input field in Netscape. The code works in IE and Opera but not in netscape6+.
Basically I have a function that is called upon exiting a form field, if the value validates properly it returns true and calls another function, if it doesn't validate the field it returns false and I want to give focus back to the sender and highlight all of the text in the field.
The problem is that while IE and opera return the curser back to the field - Netscape ignores the focus statement (I still can't find any examples as to how to return the curser and highlight the text in the field). Code:
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
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 having one td and inside td using one control(it may be any control like textbox,combobox) and am using onblur events for td and aswell as the control inside td. when am moving focus from this td to another td the parent onblur event is firing first and then child control(like textbox, combobox) onblur event is firing. The problem is am validating that entire td (what ever the value user updates) in one method. so in this scenario that validate method is calling when i move the focus onto child control. After entering the value in the child control that child control onblur event is firing and am unable to fire the parent control(td) onblur event.
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.
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.
I have two textboxes, each of them is controlled with a function called checknumber. It controlles if they are empty or a valid number and I connected this function to onBlur event of these textboxes. The problem is that when I wrote an invalid number to the first and click the second one, It gives continuously error messages. How can I solve this problem ?
1. Have the "Total" field update whenever a user changes a value in field 1 or field 2. 2. Perform some validation on those fields 3. Have the onblur and validation NOT fire when the user clicks the Cancel button.
Problem: click in the first field, don't enter a value, then try to press Cancel - the validation is happening, and I don't want it to.
This third point above seems to be the kicker. Anyone know a way I can go from a text field to clicking the "Cancel" button without firing the onBlur event? I normally don't like doing validating on-the-fly like this, but my application has the requirement of updating that Total box dynamically, so I have to perform field-level validation as I go....
I cannot seem to get these two events to work together. If I change them to say onmousedown and onmouseup, they seem to work fine. In this case, the onclick appears to work properly but onblur does not kick in.
For those who have been using Outlook Express, you must be pretty used to the fact that whenever you focus on the preview section, the header for the preview turns from grey to blue, while the text turns from black to white. Code:
I have few textfields and dropdowns in my jsp, form is submitted on clicking an image link.
In case there is an error for instance some text field is left empty, then message is displayed below respective fields ( using spans, inner html). The message is displayed onblur event of the field. So if there was an error then message is displayed, now if the user corrects the error and clicks the link then first the message disaapears ,which is desired ,but he has to click again to submit the form. please suggest a way to handle this. So that user doesn't have to click the link twice to submit the form.I tried having onmousedown and onfocus events on image , but then sometimes the form was submitted twice which gave backend errors.
I am trying to use onBlur to get to pictures to pop up when a user leaves a text box. The only requirement is that a user must enter any value into the text box if they want the pictures to pop up. Unfortunately, I cannot figure out why my code will not work
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I am currently working on a website that administers timed online tests, and we are trying to implement some measures to reduce the ability to 'cheat' while the test is running. These include disabling right clicks, and handling keystroke events. Additionally, we would like to end the test if the maximized browser popup window where the test is loaded happens to lose focus during the testing session.
I have implemented some code to call an event handler that will end the test if a window.onblur event is triggered during the session. It is working fine in Firefox, but IE seems to interpret window.onblur events differently. Basically, in Firefox I can click anywhere within the window without a window.onblur event triggering, but in IE if I click outside of the test table or form element etc. into whitespace, for instance, it fires.
In addition to using window.onblur, I have also tried top.onblur, and also putting onblur in the body tag of my html: <body bgcolor="#ffffff" onBlur="lostfocus()"> Again, both work in Firefox, but neither of these alternate methods seem to restrict IE in the appropriate manner.
So my question is this: is there any way to craft this such that IE will play nice and trigger the event ONLY when someone clicks outside of the browser window (on to the start menu, for instance)?
I'm having some trouble with the "onBlur" event in the BODY tag. Ideally, what I want to happen is that when someone leaves window A, window A executes a command. I had put
I have a couple of problems. On IE 6 (win2000), whenever I put the cursor focus on a textfield within window A, the "savePage" function is invoked. And on Mozilla Filefox 0.9.1, the event never launches even when I leave the window.
Does anyone know how I can solve these respective problems?
In IE6, I get 'Object doesn't support this property or method'. I'm using document.forms elsewhere, and I have found examples on the web using this syntax, so I'm not sure what the problem is. Can I not do this in onblur?
I have a problem with one simple script, which works in every browser, just not in IE6 and IE7. You can see the script at [uRL] - when you click on the iframe, you should see "clicked at the bottom". But it doesn't work in IE6 and IE7.