[thelist] js form validation problem - still not working

Karen J. Bowen karen at miinx.com.au
Mon Jun 17 05:28:03 CDT 2002


Burhan Khalid wrote:
> How do you mean within itself. Are you talking about recursion?

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.

> Also, I didn't get why you had two functions that did the same thing (in
> your nl.js).

yes, needs to be combined into one but went off on the "but why doesn't
this work?" tangent & as yet haven't come back!

> So, here is something that I did :
>
> function isNumeric(number) {
	<snip>
> }

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

>>Still also curious about why the first doesn't work.  It just doesn't
>>make sense.
>
> I think its because once you hit the alert button, then it shifts focus
> to the next one, because it assumes
> that you are done with that field. I tried this
>
> if(alert()) { setfocus(); } but no avail.
>
> I've seen similar behavior in different programming languages. (I'm not
> a JS expert), so I just chalked it up to that.

Hmmm.  Interesting - and more so that you say it is working in Opera!

So is this an IE and Mozilla bug I wonder??

Thanks so much again Burhan,
Karen





More information about the thelist mailing list