Trying to sort out some js code...
$(function(){
$("#name").validate({
expression: "if (VAL.match(/^[a-zA-Z][a-zA-Z_ ]*$/) && VAL) return true; else return false;",
message: "Please enter a valid name (REQUIRED)"
});
$("#email").validate({
expression: "if (VAL.match(/^[^\\W][a-zA-Z0-9\\_\\-\\.]+([a-zA-Z0-9\\_\\-\\.]+)*\\@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*\\.[a-zA-Z]{2,4}$/) && VAL) return true; else return false;",
message: "Check your email address (REQUIRED)"
});
$("#msg").validate({
expression: "if (VAL.length > 1) return true; else return false;",
message: "<p>A message is REQUIRED!</p>"
});
});
I would like to know what the purpose of the outer "$(function() { });" declaration is. Is this what forces "validity" only if all three .validate() functions return TRUE?
If so, does the main function itself return a value of TRUE or FALSE (1/0)?
I want to use an "if () {};" statement to enable/disable the submit button, depending upon the return values of all three validations, and I just want the simplest method. I suppose I could just use "if (validate() && validate() && validate()) { .strip(disable) } else { .add(disable) }" format, but as I am still js challenged .... input is welcome






Cartoon Clouds
Mountains
Sunrise
Clouds
Green Clouds
None
















Help