views:

43

answers:

2

hi expert, 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

A: 

I hope, the following link may give you a solution :

http://stackoverflow.com/questions/991367/how-to-get-the-form-parent-of-an-input

Siva Gopal
thanks Siva, this is what i'm looking for
Apache
+1  A: 

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);">
Parkyprg