according to the documentation "messages" is a property of the rule
not a method see http://docs.jquery.com/Plugins/Validation/rules

I adjusted your code to reflect that see if that makes it any better

mysite.validateFormFields = function() {

    alert('here');
    // its hitting here
    // validate contact form on keyup and submit
    $("#myForm").validate({
        alert('here');
        // its not hitting here[/b][/color]
        . / set the rules
        for the field names
        onkeyup: false,
        rules: {

            fname: {
                required: true,
                minlength: 2,
                maxlength: 20,
                validChars: true,
                nameCheck: true,
                                messages: {
                                        required: "Please enter first  name",
                                        minlength: jQuery.format("First name 
must be at least{0}
characters in length."),
                                        maxlength: jQuery.format("First name 
can not exceed {0}
characters in length."),
                                        validChars: "please supply valid 
characters only.",
                                        nameCheck: "Please enter first  name"
                                }
            },

            lname: {
                required: false,
                minlength: 0,
                validChars: true,
                nameCheck: true,
                                messages: {
                      //required : "Please enter your last name",
                      validChars: "please supply valid characters only.",
                      nameCheck: "Please enter last  name"
                        }
            }
        }
    });
    // end of validate
}

$.validator.addMethod('nameCheck', function(value) {
    if (value == '1st Name' || value == 'Surname') {
        //alert('here in if');
        return false;
    } else {
        //alert(value);
        //alert('here in else');
        return true;
    }
},'');

$.validator.addMethod('validChars', function(value) {
    var iChars = "!...@#$%^&()+=[]\\\';,./{}|\"<>?";

    for (var i = 0; i < value.length; i++) {
        if (iChars.indexOf(value.charAt(i)) != -1) {
            return false;
        }
    }
    return true;
},'');


Mean Mike

Reply via email to