hi all,
i have a javascript code like this:
return Validation.get(‘IsEmpty’).test(v) || (!isNaN(v) && !/^\s+$/.test(v));
this little code validates if an input is number only. but i want to accept numbers and dash (-) characters in the textbox.
can anyone try to manipulate this peace of code so that it can also accept dash (-) character.
thanks in advance!
objVal = document.getElementById(objId).value;
if(!isNaN(objVal) && objVal.match(/\\-/)) //do something
this is just for matching one hyphen
if you need a format like 99-9999-999-9999
so use match(/^.?\-.?\-.?\-.?/)
cheers
thanks sir reminder! works fine now!
Scimon
4
return Validation.get(‘IsEmpty’).test(v) || /+/.test(v);
Should do the trick.
thanks sir scimon! that helped a lot also. thanks!