E
ed
Hi, I was throwing together a quick validation thing, using Dean
Edward's addEvent code, and with the following code. I am trying to
cancel the onsubmit if there is an error. By setting e.returnValue =
false; I can get it not to submit in IE, but it always submits in
mozilla, regardless of that assignment. I'd like to know 1) why, and
2) how to fix this.
Thanks!
<script ...>
addEvent( window, 'load', function(){
var loginForm = document.getElementById("loginForm");
addEvent( loginForm, 'submit', function(e){
var one = document.getElementById("newpassword").value;
var two = document.getElementById("newpassword2").value;
if( (one.length != 0) && (one == two) ){
return true;
} else {
document.getElementById("error").style.display = "block";
if(e) {
e.returnValue = false; }
}
});
});
</script>
Edward's addEvent code, and with the following code. I am trying to
cancel the onsubmit if there is an error. By setting e.returnValue =
false; I can get it not to submit in IE, but it always submits in
mozilla, regardless of that assignment. I'd like to know 1) why, and
2) how to fix this.
Thanks!
<script ...>
addEvent( window, 'load', function(){
var loginForm = document.getElementById("loginForm");
addEvent( loginForm, 'submit', function(e){
var one = document.getElementById("newpassword").value;
var two = document.getElementById("newpassword2").value;
if( (one.length != 0) && (one == two) ){
return true;
} else {
document.getElementById("error").style.display = "block";
if(e) {
e.returnValue = false; }
}
});
});
</script>