Javascript validation as a condition for a second function in the same event handler
June 04, 2003
Javascript | Questionmark Perception | Snippets | Web Building
We use Questionmark quizzing software at my job to create quizzes and tutorials. One of several issues we have had with it has been a login page which did not validate for the kind of ID number we wanted to use. In fact it did not validate at all! We were told that either it couldn't be done because it would not work with the software (the login page submits some .asp variables), or it would cost us to have it done by their programmers - so we set about trying to make it happen. The problem was that it uses the onSubmit event to trigger some fancy new window actions. I wanted the validation to take place and stop the new window action as well as the "submitting" action itself. So my first thought was to put a standard validation script on an onBlur event. In other words when people moved the cursor from the validated field to the next field, the validation would occur.
Ads by Google

Posted by ellen at June 04, 2003 06:43 PM This worked in some browsers, although it was a little klunky. Unfortunately in older IE browsers, it did not work at all, probably because it was not recognizing the onBlur event properly. To make this work in the onSubmit event, I needed the validation function to return true or false, and the rest of the functions to occur only on "return true." After getting the general drift of what I needed together, I sought help from the kind folks at the CodingForums. The code they came up with was this: Download Code Here This works in all browsers I've tested so far. Many thanks to Cheesebagpipe!
Ads by Google


Ads by Google

 RSS   |   Contact Me


Ads by Google