SysTechGuy
Technical User
My company has an online application written in JavaScript where people enter personal information and submit it via the Web. Within the code, information that has to be formatted is sent to functions that test the data to see if it meets certain criteria. For instance, "State" must be entered as only two letters.
There is a problem with these specific fields when erroneous information is entered. The user enters information in the wrong format and then an exception is thrown with an "alert" method. What is suppossed to happen is the user clicks "Okay" on the message pane and then focus is put back on the field that contains the error, thereby not letting the user continue until the data is entered correctly.
What happens instead is that when the "alert" method executes and a message pane appears, the message pane will not disappear when "Okay" is clicked and the user cannot get back to the application. This only happens in FireFox and not in IE7. Here is the function for "State" that tests the data and the html tag that calls the function:
<td valign="top">
<input name="applicantState" type="text" size="5" onblur="stateCheck(document.applicationForm.applicantState);">
</td>
function stateCheck(checkThisState) {
stateString = checkThisState.value;
if ( stateString != "" ) {
stateString = stateString.toUpperCase();
if ( stateString.length == 2 ) {
checkThisState.value = stateString;
}
if ( stateString.length != 2 ) {
checkThisState.focus();
alert("State codes must be two letters only.");
}
}
}
I have tried putting the "checkThisState.focus()" method after the alert statement, which eliminate the problem of the alert message not disappearing, but the focus isn't put on the state field again, which means a user could enter unformatted data.
Again, this is only a problem in FireFox, not Internet Explorer 7. Since a significant portion of our users may use FireFox, I was wondering if there was special code I could enter so FireFox can handle this program logic.
Any input would be greatly appreciated.
There is a problem with these specific fields when erroneous information is entered. The user enters information in the wrong format and then an exception is thrown with an "alert" method. What is suppossed to happen is the user clicks "Okay" on the message pane and then focus is put back on the field that contains the error, thereby not letting the user continue until the data is entered correctly.
What happens instead is that when the "alert" method executes and a message pane appears, the message pane will not disappear when "Okay" is clicked and the user cannot get back to the application. This only happens in FireFox and not in IE7. Here is the function for "State" that tests the data and the html tag that calls the function:
<td valign="top">
<input name="applicantState" type="text" size="5" onblur="stateCheck(document.applicationForm.applicantState);">
</td>
function stateCheck(checkThisState) {
stateString = checkThisState.value;
if ( stateString != "" ) {
stateString = stateString.toUpperCase();
if ( stateString.length == 2 ) {
checkThisState.value = stateString;
}
if ( stateString.length != 2 ) {
checkThisState.focus();
alert("State codes must be two letters only.");
}
}
}
I have tried putting the "checkThisState.focus()" method after the alert statement, which eliminate the problem of the alert message not disappearing, but the focus isn't put on the state field again, which means a user could enter unformatted data.
Again, this is only a problem in FireFox, not Internet Explorer 7. Since a significant portion of our users may use FireFox, I was wondering if there was special code I could enter so FireFox can handle this program logic.
Any input would be greatly appreciated.