Faqts : Business : Programming : Shopping For You : JavaScript : Event handling

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 11 people (36%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

When validating a field with "Onchange=", how can you keep the cursor in this field in NS6?

Jan 31st, 2005 13:14
Simon Forsyth, Sean Devoy,


You have to delay the focus setting.

function validateField (f){
// blah blah field is bad so:
setTimeout ('document.' + f.form.name + '.' + f.name + '.focus()',100);
setTimeout ('window.alert (\'Invalid entry.\')', 100);
}

</SCRIPT>
</HEAD>
<BODY>

<FORM NAME="myForm">
<input type="text" name="myFld" onChange="validateField(this);">
</FORM>