Creating Password repeat/confim validation within a Contour form
Hi
So ive created a form in Contour, it's a register form and creates a Member upon clicking on submit. I have tested this with one password field and it works great but my client would like a repeat/confirm password box and it to validate before submission.
I have created the form using the Contour tools instead of the code first approach and wondered if there was an easy way to do this validation without re writing the whole form using the code first approach?
So Code first add an easy way of doing this but if you don't want to design your form in code you can hook into the event model and add extra errors into the controller modelstate
What is the best way to do the same type of validations (related form fields) but from Javascript (using Umbraco 4.11.9 and Contour 3.0.6)? Is there any example showing where to hook without to hack?
Creating Password repeat/confim validation within a Contour form
Hi
So ive created a form in Contour, it's a register form and creates a Member upon clicking on submit. I have tested this with one password field and it works great but my client would like a repeat/confirm password box and it to validate before submission.
I have created the form using the Contour tools instead of the code first approach and wondered if there was an easy way to do this validation without re writing the whole form using the code first approach?
Comment author was deleted
So Code first add an easy way of doing this but if you don't want to design your form in code you can hook into the event model and add extra errors into the controller modelstate
So you'll need to look at http://our.umbraco.org/Documentation/Reference/Events/application-startup
And the event you need is Umbraco.Forms.Mvc.Controllers.FormRenderController.FormValidate
The sender will be the controller so you can access the modelstate there and do stuff like
ModelState.AddModelError(field.Id.ToString(),
string.Format(errorMessage.ParsePlaceHolders(), field.Caption));
Comment author was deleted
Will add a code sample tomorrow , need to run now
Ok so i have
Do you know where ModelState is imported from?
I'll have a play around with it and see if i can get it working, failing that i'll wait for your code sample tomorrow.
Thanks Tim appreciate your help.
Comment author was deleted
Yeah the sender is the controller, so cast to controller and then you should be able to access the modelstate
Ok cool, getting closer
how to get the field.Id, is this the id of the Confirm Password field?
errorMessage.ParsePlaceHolders() doesnt resolve either
Hi Tim
Am i getting any closer on this? Don't suppose youve had time to knock an example together for me have you?
Cheers
Neil.
Comment author was deleted
on it :)
Comment author was deleted
Will have a working example in 30 mins
Nice one, thanks Tim, apreciate it.
Comment author was deleted
Here are the details http://www.nibble.be/?p=430
What is the best way to do the same type of validations (related form fields) but from Javascript (using Umbraco 4.11.9 and Contour 3.0.6)? Is there any example showing where to hook without to hack?
is working on a reply...