Phone Number Field Validation

Anonymous
Not applicable

Phone Number Field Validation

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 
Tags (1)
2 REPLIES 2
Josh_Hill13
Level 10 - Champion Alumni

Re: Phone Number Field Validation

A javascript would be needed. I'm sure github or a developer can help you do this.
SanfordWhiteman
Level 10 - Community Moderator

Re: Phone Number Field Validation

    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
        })
      })
  });