-1
$\begingroup$

I'm trying to validate a contact form using this code. But I could not get appropriate validations for phone number,zip code and message.

$(function() {
   $("form[name='contact']").validate({    
      rules: {
        username: "required",
        email: {
          required: true,
          email: true
        },
        phno:"required",
        zipcode: { 
        required:true,
        zipcode:true
      },
    msg:"required"
  },
  messages: {
     username: "Please enter your username",
     email: "Please enter a valid email address",
     phno:"Please enter phone number",
     zipcode:"Please enter zip code",
     msg:"Please enter message" 
  },
  submitHandler: function(form) {
     form.submit();
  }
 });
});
$\endgroup$
1

1 Answer 1

0
$\begingroup$

As mentioned in jquery validation plugin library use phoneUS and zipcodeUS instead of phno and zipcode.

$\endgroup$
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.