| Author |
code to allow negative numbers(no special charcaters,no decimal,no letters)
|
Ganeshkumar cheekati
Ranch Hand
Joined: Oct 13, 2008
Posts: 355
|
|
Hi
Can anybody provide me the code to accept only negative numerics which doesnot allow special characters, decimals and letters?
Thanks
Ganesh Kumar CH
|
SCJP5 and SCWCD1.5
Think Twice Act Wise...
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50693
|
|
|
Where is your code? What problems are you having with it? CodeRanch is NotACodeMill.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Ganeshkumar cheekati
Ranch Hand
Joined: Oct 13, 2008
Posts: 355
|
|
function allow_numericandminus_Tracking(obj){
if (!/^\d+(\d*)?$/.test(obj.value)){
obj.value= theVal = obj.value.replace(/[^0-9.]/g,''); //alert(theVal);
if(theVal>""){
obj.value=parseFloat("0"+theVal);
obj.focus()
}
}
}
above code is not allowing hyphen so please guide how to change the regular expression?
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15003
|
|
put it together
Eric
|
 |
 |
|
|
subject: code to allow negative numbers(no special charcaters,no decimal,no letters)
|
|
|