AmpleHosting
Active Member
- Joined
- Dec 17, 2009
- Messages
- 55
Hello,
Hope some smart people can help.. Having problem with a form validator.
var pass = TRUE
then some checks on fields etc,,,
if one fails then pass = FALSE
then it goes to this piece of code. which seems to returns TRUE regardless...
--------------------
if (!pass){
var focusHere = document.getElementById(offendinginput);
focusHere.focus();
alert("One or more of the required fields needs to be completed. Denoted by a *. Please complete them, then press continue again.");
return false
}
--------------------
BUT
this works like I'd expect
--------------------
if (!pass){
alert("One or more of the required fields needs to be completed. Denoted by a *. Please complete them, then press continue again.");
return false
}
--------------------
WHY does document.getElementById or focus() cause this check to fail i.e return TRUE and the form submits?
using Firefox..
Thanks
Hope some smart people can help.. Having problem with a form validator.
var pass = TRUE
then some checks on fields etc,,,
if one fails then pass = FALSE
then it goes to this piece of code. which seems to returns TRUE regardless...
--------------------
if (!pass){
var focusHere = document.getElementById(offendinginput);
focusHere.focus();
alert("One or more of the required fields needs to be completed. Denoted by a *. Please complete them, then press continue again.");
return false
}
--------------------
BUT
this works like I'd expect
--------------------
if (!pass){
alert("One or more of the required fields needs to be completed. Denoted by a *. Please complete them, then press continue again.");
return false
}
--------------------
WHY does document.getElementById or focus() cause this check to fail i.e return TRUE and the form submits?
using Firefox..
Thanks