Ajax Server Validation Question

J

John Chan

Hi,

Im doing a maintenance application in ajax and coldfusion at work on IE6
exclusively. I have a save button on each form and i have to do various
validations server side and on client side when the user clicks save i.e
check that user exists in table, check users password is the same as
password in table, check password is valid, check that logged in user is a
super user etc etc to get the correct error message. Different forms may or
may not use all of these validations and not always in the same order. At
the moment for each form, im calling the first validation when user hits
save, then in that callback function im checking to see if its been
validated, if it has then run the next validation function and so on, so its
like a cascading effect. Is there a better way of doing this? so i can reuse
code on different forms. i.e. something like the following simplified code
where validation1() and validation(3) are server side validations using
ajax.

function save(){

// check validation one

if(!validation1()){

return false;

}

// check validation two

if(!validation2()){

return false;

}

// check validation three

if(!validation3()){

return false;

}

// validation passed so save

ajaxRequest(someUrl, someCallback);

}

Any advice appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,113
Latest member
Vinay KumarNevatia
Top