EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: crosemffet on December 03, 2012, 07:59:04 AM



Title: submit a form using linkbutton
Post by: crosemffet on December 03, 2012, 07:59:04 AM
this is the code for the submit process:
$('#mainForm').form({
   onSubmit: function(){
      return $(this).form('validate');
   },
   success:function(data){
      $.messager.alert('Info', data, 'info');
   }
})
server response is: "OK"
the problem is:
if the submit button is:
<input type="submit" value="Submit">
then the alert message shows ok, but if the submit button is:
<a href="#" class="easyui-linkbutton" onClick="$('#mainForm').form('submit');">submit</a>
the submission process works ok, but the alert message response is never shown....
any reason...? what's wrong with my submission button...?


Title: Re: submit a form using linkbutton
Post by: mzeddd on December 03, 2012, 10:29:29 AM
Hi,

Try to do in this way

Code:
<a href="#" class="easyui-linkbutton" onClick="mainForm.submit();">submit</a>


Title: Re: submit a form using linkbutton
Post by: crosemffet on December 03, 2012, 10:39:19 AM
mzeddd, tanks you for your reply, but unfortunately your solution is not working.
if I use onClick="mainForm.submit();", it skips the whole validation process and the form is submitted without check the require fields, number fields, etc.
any other idea..?


Title: Re: submit a form using linkbutton
Post by: crosemffet on December 03, 2012, 11:00:36 AM
finally find the solution by myself:
onClick="$('#mainForm').submit();"
do the trick ! .
thanks all for your support,