Search the Community
Showing results for tags 'formatting fields'.
-
Multiple JavaScripts for formatting
ECDatabase posted a topic in User JavaScript and CSS Discussions
I am trying to format multiple fields on a page. The first is the phone number, which I found the JavaScript for on the JavaScript forum. My issue is that I need to format phone number, social, and a tax-ID on one page and I am unsure how to accomplish this task. For phone number I am using the script below, plus I found another for formatting a social on StackExchange, but my JavaScript reading/writing skills are sub-par and I did not combine these correctly. Then I want to add in the option to format the tax ID as well, which is ##-####### (2 digits, dash, 7 digits). <SCRIPT LANGUAGE="JavaScript">function f_a(v_id){return document.getElementById(v_id);}f_a('EditRecordPhone_Number').maxLength = 14;f_a('EditRecordPhone_Number').onkeyup = function(v_e){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));};}function(){document.getElementById("SSN").onkeyup = function() {var val = this.value.replace(/\D/g, '');var newVal = '';if(val.length > 4) {this.value = val;}if((val.length > 3) && (val.length < 6)) {newVal += val.substr(0, 3) + '-';val = val.substr(3);}if (val.length > 5) {newVal += val.substr(0, 3) + '-';newVal += val.substr(3, 2) + '-';val = val.substr(5);}newVal += val;this.value = newVal;};</SCRIPT> -
How do I make my fields check and validate if the entered field is following a specified format? Like the email validation for example. I would like to have the same for fiscal ID's, etc. Any ideas?
- 1 reply
-
- java script
- formatting
-
(and 1 more)
Tagged with: