Topic: Prevent submit to work if form not valid - getFormValues

Hi,
I use xajax on my website and I try to make it work with bootstrap validator.

When the form is not valid I get information from validator but the submit button submit anyway. Is there anyway I could use the isDefaultPrevented with XAJAX?

I've tried do that but it doesn't work - I always get "error" no matter if form is valid or not:

<script type="text/javascript">
$('#myForm').validator().on('submit', function (e) {
  if (e.isDefaultPrevented()) {
     alert("error");
  } else {
    alert("ok");
  }
})
</script>

<form id="myForm" action="javascript: void(0);" onsubmit="xajax_saveForm(xajax.getFormValues('myForm'));" method="post"> 

Thank you

Re: Prevent submit to work if form not valid - getFormValues

Hey,

try this?

<script type="text/javascript">
$('#myForm').validator().on('submit', function (e) {
  if (e.isDefaultPrevented()) {
     alert("error");
  } else {
    alert("ok");
xajax_saveForm(xajax.getFormValues('myForm'));
  }
})
</script>
<form id="myForm" action="javascript: void(0);"  method="post"> 

Re: Prevent submit to work if form not valid - getFormValues

Wow that was quick.

Yeah, that works why I didn't figured it myself. Thank you!

Now I have another problem, because the author of the bootstrap validation plugin didn't turn off validation of the hidden (collapsed in bootstrap) fields and the form wont submit but that's not XAJAX problem.