Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    May 01, 2013 @ 16:23
    Warren Buckley
    0

    How do I validate with a confirm email field?

    Hello all,
    I am trying to build an Umbraco contour form that has the following fields in it:

    Email and Confirm Email address. I want to run some validation to ensure that both fields match, otherwise I want to throw a client side & server side validation errors on this.

    Has anyone done this before and if so, how have you achieved it?

    Cheers,
    Warren :)

  • Rodske 74 posts 104 karma points
    May 02, 2013 @ 01:53
    Rodske
    1

    Client-side as follows:

    var $inputEmail = $('.emailaddress input');
    var $inputConfirmEmail = $('.confirmemailaddress input');
    $inputConfirmEmail.attr('equalto', '#' + $inputEmail.attr('id'));                                  
    $('form').validate().settings.messages[$inputConfirmEmail.attr('id')].equalTo = $inputConfirmEmail.attr('data-val-regex');

    Server-side:

    Are you using razor?

     

  • Comment author was deleted

    May 02, 2013 @ 09:15

    Easiest to do with code first: http://www.nibble.be/?p=205

    If you don't have a code first form you can still hook into the server side validation there is an event available 

    Umbraco.Forms.Mvc.Controllers.FormRenderController FormValidate

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    May 02, 2013 @ 10:45
    Warren Buckley
    0

    Hey Tim,
    We are not using CodeFirst as the client will be creating many more forms so can't go down that road unfortunately.

    So with the event do I just hook into it the FormValidate event in a class?
    Also will it fire for all forms or just a specific form?

    Cheers,
    Warren :) 

  • Comment author was deleted

    May 02, 2013 @ 10:46

    Fires for all forms

Please Sign in or register to post replies

Write your reply to:

Draft