简体   繁体   English

我如何在jQuery.validator中修复代码

[英]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. 并使用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', class =“ tooltip”是我添加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. 看一下validate()函数配置的messages参数。

$('#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. 您还可以使用errorPlacement参数以编程方式根据需要定位新元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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