So what does it do?
Well it is a client side javascript validator plugin that works with your existing constraints object. All you have to do is install it then put single tag on your page and you get instant javascript validation for your existing forms.
To install:
grails install-plugin javascript-validator
Next simply add this tag to your form page. This will show the errors as an alert box.
<jv:generate domain="book" form="bookForm" display="alert" />
Finally you then need to add an onsubmit event to your form. I may make this optional in the next release. But you need it for now.
<form action="/save" method="post" name="bookForm" id="bookForm" onsubmit="return validateForm(this);" >
...
</form>
If you want the error messages to show as list on the page do this:
<jv:generate domain="book" form="signUpForm" display="list" container="errors"/>
If you want validation on command objects then do this:
<jv:generate command="signUpCommand" controller="signUp" form="signUpForm" display="alert" />
<jv:generate command="signUpCommand" controller="signUp" form="signUpForm" display="list" container="errors"/>
That should get you going.
I need to write up the full documentation but will try to do that at the weekend. For now i am off to sleep.
Enjoy...
4 comments:
I thought it was going to be some boring old post, but it really compensated for my time. I will post a link to this page on my blog. I am sure my visitors will find that very useful.
Having read this post, I have learned for myself a lot of the new. Thanks
Thanks! This is a very good manual!
The best plugin for Javascript, I search it, thank you.
Post a Comment