micjohnson
Programmer
Here is my question.
I have 3 form fields(Proj name, description and userid). Proj name and Proj description are new inputs from user. But for the thrid field "userid", I need to verify the existence against DB.
As now all 3 validations are working except the userid ajax validation when displays "The user does not exists" alert message and proceed to submit form instead of halt on the page.
What do I need to do to stop the flow if the user does not exists and make the customer to type a valid userid?
Thanks in advance.
fucntion checkForm(){
// Validate Proj name
if (document.form1.ProjtName.value.length == 0)
{
alert("Please enter a Project Name");
document.form1.ProjectName.focus();
return false;
}
// Validate Proj description
if (document.form1.ProjDescription.value.length == 0)
{
alert("Please enter a Project Description");
document.form1.ProjDescription.focus();
return false;
}
//AJAX call to validate userid
if (validateUserid() == false){
return false;
}
return true;
}
// Validate userid
validateUserid = function (userid){
if ($.trim(userid.value) != ''){
$.getJSON("../com/user.cfc", {
method: 'getUserInfoJSON',
attuid: userid.value,
returnformat: 'json'
}, function(strClient){
if (strClient == '') {
alert('The user does not exists.');
return false;;
}
});
}
};
I have 3 form fields(Proj name, description and userid). Proj name and Proj description are new inputs from user. But for the thrid field "userid", I need to verify the existence against DB.
As now all 3 validations are working except the userid ajax validation when displays "The user does not exists" alert message and proceed to submit form instead of halt on the page.
What do I need to do to stop the flow if the user does not exists and make the customer to type a valid userid?
Thanks in advance.
fucntion checkForm(){
// Validate Proj name
if (document.form1.ProjtName.value.length == 0)
{
alert("Please enter a Project Name");
document.form1.ProjectName.focus();
return false;
}
// Validate Proj description
if (document.form1.ProjDescription.value.length == 0)
{
alert("Please enter a Project Description");
document.form1.ProjDescription.focus();
return false;
}
//AJAX call to validate userid
if (validateUserid() == false){
return false;
}
return true;
}
// Validate userid
validateUserid = function (userid){
if ($.trim(userid.value) != ''){
$.getJSON("../com/user.cfc", {
method: 'getUserInfoJSON',
attuid: userid.value,
returnformat: 'json'
}, function(strClient){
if (strClient == '') {
alert('The user does not exists.');
return false;;
}
});
}
};