开发者

how to pass form name dynamically into jquery for validation [duplicate]

This question already has answers here: How to get the conta开发者_StackOverflow社区ining form of an input? (11 answers) Closed 3 years ago.

i'm using jquery for form validation, where when i click save button, the code is as below

<input type="submit" value="Save" id="button" name="Save" onClick="save(this,'/Web/controller',this.form);">

and the javascript is as below

function save(ele,servlet,formName){
$(document).ready(function() {
  $("#fmyFormName").validationEngine({    //how to pass form name dynamically here from js
     submitHandler: function(form) { 
        $(form).ajaxSubmit(); 
     } 
  })
 });
}

so i want to create generic javascript so its can handle any form, so how can i pass the form name into jquery dynamically, i try few combination such as form[id=strcmd.name],... but not work, can anyone help


You can use in < form > tag the onSubmit method to make any necessary checks. You can pass the form as parameter, like this:

<form action="..." method="..." onsubmit="return checkForm(this);">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜