简体   繁体   中英

How can i fix code in jQuery.validator

I want to check validation when user sign up. so, code is

  <span class="input_label">
  <input type="text" name="firstname" id="firstname" required="required">
  <label>FIRST NAME *</label>
  </span>

and use jQuery.validator.

after that code is appeared

<span class="input_label">
<input type="text" name="firstname" id="firstname" required="required">
<label>FIRST NAME *</label>
</span>
<div for="firstname" class="tooltip">Please enter your first name</div>

class="tooltip" is i add errorClass: 'tooltip', errorElement: 'div',

How do i have to do.. if I insert code Please enter your first name in tag?

Take a look at the messages parameter for the validate() function config.

$('#form_id').validate({
   messages: {
      firstname: "Please enter your first name"
   },
   errorClass: 'tooltip',
   errorElement: 'div'
});

You could also use the errorPlacement parameter to programatically position the new element as needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM