简体   繁体   English

jquery 单击锚点时必填字段验证器

[英]jquery required field validator on click of anchor

I want to validate textbox on click of anchor with jquery required field validator http://docs.jquery.com/Plugins/Validation Can you let me know how can I do that?我想使用 jquery 必填字段验证器http://docs.jquery.com/Plugins/Can you know howValidation 验证文本框

Bind a event to the click of this anchor with this:使用以下方法将事件绑定到此锚点的单击:

$("#field_id_you_want_to_validate").validate({
  rules: {
    required: true
  }
})

Let say you have anchor with id "myAnchor".假设您有 ID 为“myAnchor”的锚点。 This is how i write the code这就是我编写代码的方式

$("#myAnchor").click(function(){
// Validate the Textbox that you want 

$("#textboxid").attr('class', 'required');

});

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

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