Not an answer to your question, but why not wait till they click submit before validating? You could still put the focus on the offending fields.
Ade -----Original Message----- From: Aidan Whitehall [mailto:[EMAIL PROTECTED]] Sent: 12 February 2003 11:58 To: [EMAIL PROTECTED] Subject: [ cf-dev ] OT: Preventing infinite alert loop in form field validation Just gonna try this on CFDev cause this is urgent, you're fast off the mark and JS-Jive are a sleepy lot... If you're doing form validation in consecutive fields where the error displays an alert and puts focus back on the offending field, what's the "best" way of preventing the browser from getting into an infinite loop where it keeps alerting the error message? Not the real code, but the gist is something like this: function(field) { if (isNaN(field.value)) { alert("Please enter a number."); field.focus(); } } <input type="" onBlur="isNumber(this);"> <input type="" onBlur="isNumber(this);"> If neither of the fields have content, you - tab off field one - focus goes to field two - validation for field one kicks in, alerts the error and puts focus on field one - the onBlur event on the second field fires - which fails the validation test, putting focus on field one, ad nauseam. Thanks! -- Aidan Whitehall <[EMAIL PROTECTED]> Macromedia ColdFusion Developer Fairbanks Environmental Ltd +44 (0)1695 51775 ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED] -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
