Jump to content

bpasko

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by bpasko

  1. @DefinitelyNot31337 or anyone else, I am wondering if you can help me with a situation related to the above. I used your script above, which worked beautifully when applied to one field. I edited it slightly to be EditRecord because I am working with a details page. My problem is that I have 11-12 phone fields inside my details page. And when I duplicate the script 11-12 times, I run out of space in my footer. I don't have enough coding experience to know how to merge or make the script apply to multiple fields. If you could suggest a workaround I would be very grateful. Thank you, Brian P.S> Here is the script I am using, which works perfectly for individual fields: <script> var field = 'EditRecordPhone2'; var input = document.querySelector('#' + field); input.maxLength = 14; input.onkeyup = telephize input.onkeydown = telephize function telephize(v_e) { // this.value = this.value.replace( /\D+/g, "" ).replace( /([0-9]{1,3})([0-9]{3})([0-9]{4}$)/gi, "($1) $2-$3" ); //mask numbers (xxx) xxx-xxxx v_e = v_e || window.event; if (v_e.keyCode >= 65 && v_e.keyCode <= 90) { this.value = this.value.substr(0, this.value.length - 1); return false; } else if (v_e.keyCode >= 37 && v_e.keyCode <= 40) { return true; } var v_value = (this.value.replace(/[^\d]/g, '')); if (v_value.length == 7) { this.value = (v_value.substring(0, 3) + "-" + v_value.substring(3, 7)); } else if (v_value.length == 10) { this.value = ("(" + v_value.substring(0, 3) + ") " + v_value.substring(3, 6) + "-" + v_value.substring(6, 10)); }; } document.querySelector('#caspioform').onsubmit = function(e) { e.preventDefault(); if (input.value.length >= 14){ this.submit(); } else { alert('Please input a valid phone number'); input.focus(); } } </script>
×
×
  • Create New...