Simple Client Side Ajax Validation
But when do the same with an Ajax call .. the Ajax call goes out without a validation.. which is what you don’t want. The call should only go out if the validation passes . Now faced with this I started to write a custom method … but on some reading up, found out that there actually exists a way to do this through the Plugin itself.
Something like
[javascript]
function validateForm() {
.
.
if ($(‘#form’).validate().form()) {
// (Put your Ajax Call here)
}
}
[/javascript]
[html]
<g:formRemote name="searchPage" id="searchPage" url="${[controller:’eventInstance’,action:’executeSearch’]}" update="searchUpdate" before="return validateSearchForm()">
.
.
</g:formRemote>
[/html]
With a Javascript function
[javascript]
function validateSearchForm() {
if ($(‘#searchPage’).validate().form() && checkDate()) {
return true;
}
else {
return false;
}
}
[/javascript]
So in this way the page would be Ajaxified if both of those methods returned true …
Hope this helps ..
Manoj Mohan
Manoj (at) Intelligrape (dot) com
Cool stuff bro!!….keep up the good spirit!!
Hi, helpful post.
im just wondering if i can call a javascript function like
submitForm(){
..
ajax call here
}
then the validation is separate..im just confused though