how to pass form name dynamically into jquery for validation [duplicate]
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);">
精彩评论