views:

9

answers:

1

Hi All,

I am using the Jquery Validation plugin (http://docs.jquery.com/Plugins/Validation) to valid a form on my page.

I am using the "required" class to validate an input on my page and want to show custom required text when the field is empty. How can I do this.

Code is as follows:

    <script>
    $(document).ready(function() {
      $("#phonetypeform").validate({
      });
    });
      </script>

<form id="phonetypeform" name="register" action="register.php">

<input class="required" type="text" name="name" />

<button type="submit">Submit</button>
</form>
+1  A: 

Use the messages option with the name of the input underneath and the rule: "message" underneath that, like this:

$(document).ready(function() {
  $("#phonetypeform").validate({
      messages: {
          name: { required: "Custom Message" }
      }
  });
});​

You can test it out here.

Nick Craver