RPeraltaJr
9/8/2017 - 3:33 AM

Remove Dashes from Phone Number input

function fsPhoneFormat() {
    var x = document.getElementById("fsPhone");
    x.value = x.value.replace(/-/g, ""); // remove any dashes
    x.value = x.value.replace(/^1/, ''); // remove '1' if it is first number
}
<!-- 
  Rules:
  1. First number cannot be number 1.
  2. Number cannot have dashes.
-->
<input type="phone" name="Phone" placeholder="Phone*" pattern="^[2-9][0-9]*" title="Cannot begin with 1." id="fsPhone" onblur="fsPhoneFormat()" required>


<!-- 
  Rules:
  1. First number cannot be number 1.
  2. Number cannot have dashes.
  3. Fourth number cannot be number 1.
  4. Min number length is 10.
-->

<input type="phone" name="phone" placeholder="Phone" pattern="^[2-9]{1}[1-9]{2}[2-9]{1}[1-9]{2}[0-9]{4}" title="Please enter a valid phone number with a minimum length of 10 numbers." min-length="10" id="fsPhone" onblur="fsPhoneFormat()" required>