[thelist] js form validation problem

Karen J. Bowen karen at miinx.com.au
Thu Jun 13 09:02:00 CDT 2002


I'm having a problem with returning the focus to the correct form
element after doing simple js validation.

The JS is:

function chkNum(sName) {
	var sv = sName.value
	if (isNaN(sv)) {
		alert("Please enter a valid number.");
		sName.select();
		sName.focus();
	}
	return true;
}


And the form element calls it thusly:

<input type="Text" name="stock<%=i%>" class="txtbox2" size="4"
onchange="chkNum(this)">

The problem is that while the correct element is being selected, the
focus is going to the next element.

This is bizarre, and I just can't see why it's happening.  (it's
occurring in both moz & ie)

Thanks for any help!

Karen






More information about the thelist mailing list