|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to do form validation using onBlur. in IE, it works fine (of course) but in NS i get an infinite loop upon calling the validation function...
call: <input type="text" name="AmortTerm" size=20 maxlength="3" value="<%= RstObj("NbrMonths") %>" onFocus="this.select()" onBlur="ChkNumeric(this)"> function: function ChkNumeric( FieldName ) { var ValueSent = FieldName.value; var Vlen = ValueSent.length; var ch; for (var i = 0; i < Vlen; ++i) { ch = ValueSent.substring(i,i + 1); if (ch < "0" | | "9" < ch) { alert ("Please enter a valid number, decimals and other punctuation are not allowed"); SetFocus(FieldName); return false; } } return true; } // ChkNumeric any ideas how to make this work in NS without looping infinitely? thanks, josh leonard Dexma, Inc |
|
#2
|
|||
|
|||
|
When AmortTerm has a valid number entered in it, do you still get an infinite loop? or only when the number is invalid?
if so, then maybe in NS your SetFocus(FieldName) sets the focus on AmortTerm (which is correct behavior) but at the same time causes it to "blur" so your ChkNumber(this) gets called again without giving you a chance to correct the number entered. If that is the case, try having a global var called isChecking, and check against it within your function to make sure this kindof thing doesnt happen. var IsChecking = false; function ChkNumberic( FieldName ) { if (isChecking) return; isChecking = true; var ValueSent = FieldName.value; var Vlen = ValueSent.length; var ch; for (var i = 0; i < Vlen; ++i) { ch = ValueSent.substring(i,i + 1); if (ch < "0" | | "9" < ch) { alert ("Please enter a valid number, decimals and other punctuation are not allowed"); isChecking = false; SetFocus(FieldName); return false; } } isChecking = false; return true; } // ChkNumeric Just an idea, hope it helps. ThePope |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Netscape and onBlur for validation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|