• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

onblur errors in Netscape

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.
We are doing form validation using the onBlur event to make sure each textbox is filled before moving on to the next one. However this produces an endless loop in Netscape and you have to close the browser to escape (not very user friendly ).
I have searched the archives here and several people recommended the onBlur event for validation. Has anyone found a way around the Netscape problem or do you all code for IE only?
Here is my code:
<SCRIPT LANGUAGE="JavaScript">
<!--
function verify(field) {
var str = field.name;
if(field.value == "") {
alert("The field is " + str);
field.focus();
}
}
//-->
</SCRIPT>
....
<FORM>
SSN:<input type="text" name="ssn" onBlur="verify(this)" maxlength="9">
First Name: <input type="text" name="firstName" onBlur="verify(this)">
Last Name:<input type="text" name="lastName" onBlur="verify(this)">
</FORM>
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm getting the same thing thing in IE6! About to chuck my box out the window.
Here's my javascript:
function checkForNull(elm,elmVal){
if(elmVal==""){
alert("Please enter a value.");
elm.focus();
return false;
}
}
and in the form:
<input ..... onBlur="checkForNull(this,this.value);">
Seems innocent enough, but loops endlessly. I'm dyin' here. Can anyone help with this pleeeease?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the reason why is that it will always be blurred, you need to refocus it. See if this works.
Also look in my sig. below:
onblur="ValidateIt(this)"
function ValidateIt(X){
if(X.value=""){
alert('Error ;
X.focus();
}
else return true;
}
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic