1

I've created a module which adds an additional field to the checkout, called 'email-confirm'. I want to check that the value in this field is equal to the first email entry, but I'm unsure how to do this.

1

The registration form is worth having a look over it uses the following:

data-validate="{required:true, equalTo:'#password'}"

So based on that, if you have a template you should add a specific validator for equalTo and the target which you wish to compare it to.

If your using it through xml to build your form similar to the checkout I expect that you can add it as an item eg:

<item name="validation" xsi:type="array">
    <item name="equalTo" xsi:type="string">#target</item>
</item>

The above I've not verified however but believe that way should work.

  • Thanks for you response, I've just tried this method and while it seems to be valid xml it doesn't seem to apply the validation. I've replaced the #target with #customer-email and but when I submit the form without filling this in - it succeeds rather than prevents you from submitting (as it should). – ol'bob dole Nov 11 '16 at 16:48
  • This didn't work due to another issue in my xml, works now - thanks. – ol'bob dole Dec 1 '16 at 13:05
  • I'm trying to get this to work using a overwrite on the password.html but i keep getting the error: 'msg.replace', any idea? – Sanne Jun 27 '18 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.