autoformat mobile number (xxx) xxx-xxx codepen
// For this type format xxx-xx-xxxx
$(document).on('keyup','your input element',function(){
let text=$(this).val()
text=text.replace(/\D/g,'')
if(text.length > 3) text=text.replace(/.{3}/,'$&-')
if(text.length > 6) text=text.replace(/.{6}/,'$&-')
$(this).val(text.substring(0,11));
});
//For this type format (999) 999-9999
$(document).on('keyup','Your input element',function(e){
let text=$(this).val()
text=text.replace(/\D/g,'')
text=text.replace(/.{0}/,'$& ( ' )
text=text.replace(/.{6}/,'$& ) '); //Add hyphen at pos.4
text=text.replace(/.{12}/,'$&-') //Add hyphen at pos.8
$(this).val(text.substring(0,17)); //Set the new text
});
Also in JavaScript:
- react materialize cdn
- react how to create range
- disable js in chrome dev tools
- pi in js
- passport middleware check if authenticated
- jest async test fetch api
- kill all node processes
- js hoisting
- js array.pop
- get current directory vbscript
- javascript method to see if item exists in array
- CocoaPods could not find compatible versions for pod "ReactCommon/jscallinvoker"
- vuejs
- mlutiple css jquery
- formating decimal hours as hours and minute javascript
- react js documentation
- react native touchableopacity disable
- bootstrap in javascript
- inline math mathjax
- jest input value
- jquery use variable in string "without" concatenate
- how to create multiple folders at once in node js
- regex changing before last dot value
- how to create response time router node js