Menu icon Foundation
Abide - Phone Number Patterns

Hi, I think we all been looking for this. So this would be a great to be Answered properly.

Abide is great for validate form field in Foundation it has a lot of patterns you can use except one th Telephone numbers.

I would like to use a pattern for Mobile Phone number validation.

+44123456789 etc.

Thank you.

formvalidate

Hi, I think we all been looking for this. So this would be a great to be Answered properly.

Abide is great for validate form field in Foundation it has a lot of patterns you can use except one th Telephone numbers.

I would like to use a pattern for Mobile Phone number validation.

+44123456789 etc.

Thank you.

Alok Jethanandani over 5 years ago

Hey peter, from what I can understand you want to check to see if the mobile phone number has:

1) numbers
2) length of 11 digits

If that is correct try this code:

 $(document)
  .foundation()
  .foundation('abide', {
    patterns: {
      mobile_number:^07([\d]{3})[(\D\s)]?[\d]{3}[(\D\s)]?[\d]{3}$
    }
  });

Or head on over to Regexlib.com to look for the regular expression that matches your mobile number criteria, if this one doesn't work.

http://regexlib.com/Search.aspx?k=uk+mobile+phone&c=-1&m=-1&ps=20

And then apply that custom abide pattern to your form field:

<form class="custom" data-abide>
  <label>Mobile Number</label>
  <input type="text" pattern="mobile_number" required>
</form>