View Full Version : Simple form validation question

04-24-2008, 06:48 AM
I have a form that is submitted by a button that calls an ajax request. I want that same button to have another onclick event that checks the form is valid. How do i do it? New to javascript obviously. :confused:
This the button now:

<input type="BUTTON" onclick="ajaxFunction()" value="ADJUST">

04-24-2008, 06:50 AM
<input type="BUTTON" onclick="ajaxFunction();validateFunction();" value="ADJUST">

04-24-2008, 07:18 AM
That was very good but the ajaxFunction gets called once the user clicks ok that the fields are empty
the ajaxFunction simply calls this function for each field:

function isEmpty(elem, helperMsg){
if(elem.value.length == 0){
return true;
return false;

so the server side code gets executed whether it is valid or not. I need the ajaxFunction to be called only if validation is TRUE.

04-24-2008, 07:33 AM
Then simply change the order of calling of these two functions Or call the second function at the end of the other's body.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum