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 2089 posts 4578 karma points MVP ∞ admin hq 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?

     

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    May 02, 2013 @ 09:15
    Tim Geyssens
    1

    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 2089 posts 4578 karma points MVP ∞ admin hq 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 :) 

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    May 02, 2013 @ 10:46
    Tim Geyssens
    0

    Fires for all forms

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies