[thelist] JS field validation ?
Winfried Huslik
winfried at huslik.de
Tue Feb 20 14:09:24 CST 2001
Be careful with alerts! They mess up things sometimes.
Better do the calculation first and later show the alert.
In your case I would simply change the order by checking for a number
first and if that fails, throw the alert.
Winfried Huslik
On 2001-02-20 18:56 Uhr, Bob Davis (bobd at members.evolt.org) wrote:
>
>Hi all,
>
>I'm having a little problem getting something to work. I am trying to
>determine whether a value entered into a form field is a number, and, if it
>is, to call another function.
>
>My validation function is:
>
>function CheckRange(box) {
> if (isNaN(box.value)) {
> alert('You must enter a number')
> }
> else { valChange() }
>
> }
>
>and the form field looks like this:
>
><input type="text" onChange="CheckRange(this)" size=1 name="xaxis" value="0"
>tabindex="1">
>
>For some reason, if I enter a non-numeric value into the field, the alert
>box does come up, but the valChange function is called. It shouldn't be,
>right?
>
>Obviously, I've made a mistake somewhere. I just don't know where it is.
>
>Can anyone offer some advice?
>
>TIA,
>bob
>
>--
>
>bob davis
>bobd at members.evolt.org
>
>
>---------------------------------------
>For unsubscribe and other options, including
>the Tip Harvester and archive of TheList go to:
>http://lists.evolt.org Workers of the Web, evolt !
More information about the thelist
mailing list