Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 仅验证任何特定提交按钮的几个字段_Jquery_Jquery Validate - Fatal编程技术网

Jquery 仅验证任何特定提交按钮的几个字段

Jquery 仅验证任何特定提交按钮的几个字段,jquery,jquery-validate,Jquery,Jquery Validate,我正在使用jQuery验证插件() 我面前有一个非常奇怪的情景 我有一个表单,有5个不同的提交按钮 <form id="frm1" name="frm1" method="post" action="save.php"> ------- input fields here--- <input type="submit" name="submit" value="update account info"> ------- input fields here--

我正在使用jQuery验证插件()

我面前有一个非常奇怪的情景

我有一个表单,有5个不同的提交按钮

<form id="frm1" name="frm1" method="post" action="save.php">
  ------- input fields here---
  <input type="submit" name="submit" value="update account info">

  ------- input fields here---
  <input type="submit" name="submit" value="update address info">

  ------- input fields here---
  <input type="submit" name="submit" value="update credit-card info">

  ------- input fields here---
  <input type="submit" name="submit" value="update bank info">

  ------- input fields here---
  <input type="submit" name="submit" value="update other info">
</form>
对于“更新其他信息”提交,我需要使用以下ID验证以下输入字段:

 cust_fname
 cust_lname
 cust_age
 married
 childerns

如何实现以下目标?

创建5个单独的表单是最简单的方法。然后可以将不同的特定验证绑定到每个表单

或者,您可以将验证绑定到每次单击“提交”按钮。 假设您将submitbutton更新为:

  <input type="submit" id="button_1" name="submit" value="update account info">
对每个按钮都这样做

编辑:Live已被弃用

$("#button_1").on("click", function() {
    $("#frm1").validate({
        rules: {
            cust_fname: "required", // of course set different options for every field
            cust_lname: "required", 
            cust_age: "required"
        }
    }); 
});
. 用它来代替。
$("#button_1").on("click", function() {
    $("#frm1").validate({
        rules: {
            cust_fname: "required", // of course set different options for every field
            cust_lname: "required", 
            cust_age: "required"
        }
    }); 
});