Phone Number Field Validation | Community
Skip to main content
March 30, 2015
Question

Phone Number Field Validation

  • March 30, 2015
  • 2 replies
  • 1336 views
Hi,

Does anyone know how to custom add a "+" in front of the phone field type?

For example, if someone enters "123-456-7891" - is there a way to populate it as "+1-123-456-7891"? 

Thanks!
Christina 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Josh_Hill13
Level 10
March 30, 2015
A javascript would be needed. I'm sure github or a developer can help you do this.
SanfordWhiteman
Level 10
March 30, 2015
    MktoForms2.loadForm( "//app-zz01.marketo.com", "AAA-BBB-CCC", 999, function(form){
      form.onSubmit(function(form){
        var enteredPhone = form.getValues().Phone;
        if ( !/^\+/.test(enteredPhone) ) form.setValues({
          Phone : '+'+enteredPhone
        })
      })
  });