|Number of votes:||0|
I recently got a question from a partner if it is possible to add validation to check if two fields are equal to each other. The scenario was that a user is asked for their email address and then asked to confirm it. I have already blogged about how to add a simple regular expression validation but this requires a bit more code but not much. Anders Hattestad wrote a great blog post on how to extend XForms and with the help of his blog post I got my validation working.
I start by adding a regular expression validation in my global.asax.
When I select two different textboxes I mark both as similar in the drop down list.
On the event control.ControlsCreated += I attach and add some code.
First thing I do is that I try to find the regular expression validation added with my dummy regex.
I then add the controls to a list and the controls they validate. I then remove the regular expression validation controls and add a compare control saying that both controls should be equal
The end results are that if they are not equal it will show
Please login to comment.