Tricky Dicky 3 - checking telephone number

idaryl

Avatar: idaryl

2008-02-13 08:21

No 3 is an ongoing series... This one should work in all versions...

OK you have two fields in the orders_delivery both require numbers - the ZipCode and the Telephone, but.... text can be input - so, to restrict the user to numbers only - add this in the field variable itself:

onkeyup="this.value=this.value.replace(/\D/g,'')" onblur="this.value=this.value.replace(/\D/g,'')"

eg: <input type="text" name="sTelephone" value="$aData[sTelephone]" class="input" maxlength="30" onBlur="saveUserData( this.name, this.value )" onkeyup="this.value=this.value.replace(/\D/g,'')" onblur="this.value=this.value.replace(/\D/g,'')" />

What this will do is restrict the user to only being able to enter numbers - no text allowed - it should help cut down on form mistakes or errors.

Should work straight up with no extra finessing.......

» Quick.Cart v2.x

idaryl

Avatar: idaryl

2008-02-13 09:27

Addendum______

The fact that both fields already use the onBlur function; this extra onBlur will probably/might cause an exception - a fix is in order:

replace the onBlur wih this:
onBlur="return (function(){var r= saveUserData( this.name, this.value ) this.value=this.value.replace(/\D/g,'') return r;})();"

It's a dual function, function and should circumvent any probable resulting errors.

Back to top
about us | contact