southbeach
Programmer
I have a simple form with a number of text fields, check boxes and radius buttons.
The text fields need to be validated for data type format (phone, date, time, etc.). I use the onblur behavior to check entered value, validate and proceed accordingly.
Now, image fields PHONE1 and PHONE2, they are both next to once another. the onblur calls for a script which in turn makes an AJAX call to a PHP script. The script checks and validates data and returns a response ... All of this is working except that when the data is not valid, the script sets focus to the field based on its ID but some how, the same script is called by the onblur of the 2nd field as the first regains focus.
In other words, user presses TAB from PHONE1 - routines validates, fails and set focus to PHONE1. The browser, naturally attempts to place cursor in PHONE2 and it appears that the .focus() command triggers the same routine but for PHONE2.
I would not have a problem if not because I am using a "shared" layer where to display message returned by PHP script with a detailed explanation of why data may have failed.
How do I skip the onblur action for PHONE2 if PHONE1 validation had failed?
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
The text fields need to be validated for data type format (phone, date, time, etc.). I use the onblur behavior to check entered value, validate and proceed accordingly.
Now, image fields PHONE1 and PHONE2, they are both next to once another. the onblur calls for a script which in turn makes an AJAX call to a PHP script. The script checks and validates data and returns a response ... All of this is working except that when the data is not valid, the script sets focus to the field based on its ID but some how, the same script is called by the onblur of the 2nd field as the first regains focus.
In other words, user presses TAB from PHONE1 - routines validates, fails and set focus to PHONE1. The browser, naturally attempts to place cursor in PHONE2 and it appears that the .focus() command triggers the same routine but for PHONE2.
I would not have a problem if not because I am using a "shared" layer where to display message returned by PHP script with a detailed explanation of why data may have failed.
How do I skip the onblur action for PHONE2 if PHONE1 validation had failed?
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.