[thelist] js form validation problem - still not working

Burhan Khalid burhankhalid at members.evolt.org
Mon Jun 17 06:02:00 CDT 2002


>
> yep - so doing this:
>
> function chkStockNum(fld, num, wine) {
>    var sv = fld.value
>    if (isNaN(sv)) {
>      fld.value = chkStockNum(prompt("Please enter a valid
> number for the
> bottles of "+wine), num, wine);
>      return false;
>    }
> }
>
> with recursive call on the prompt.  Haven't looked further
> into this yet.
>

Actually, I was working on something along those lines. Here is what I
have got so far (not 100% complete, but should
get you going).

function isNumeric(number,fld) {

...
if (fld) { fld.value = number; return true; }
	return true;
}
function chkStockNum(fld, num, wine) {

	var sv = fld.value
	if (!sv) { sv = fld; }

	if (!isNumeric(sv)) {
		var temp = prompt("Please enter a valid number for the
bottles of "+wine);
		if (!isNumeric(prompt("Please enter a valid number for
the bottles of "+wine),fld))
		{	fld.value = temp; }
		else { chkStockNum(temp,num,wine); }
		return false;
	}

...


> JS has the isNaN() function, which does the same thing. :)

I read somewhere that isNaN() will only check the first digit. So,
something like 45rs would pass.
Let me see if I can find that resource...

>
> Hmmm.  Interesting - and more so that you say it is working in Opera!
>
> So is this an IE and Mozilla bug I wonder??
>

Well, its is 4 AM here, so my eyes may be playing tricks on me. (Checks
Opera again). Yeap. Works.

> Thanks so much again Burhan,
yw,
Burhan





More information about the thelist mailing list