IntelliJ Java IDE
The moose likes HTML, CSS and JavaScript and the fly likes code to allow negative numbers(no special charcaters,no decimal,no letters) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "code to allow negative numbers(no special charcaters,no decimal,no letters)" Watch "code to allow negative numbers(no special charcaters,no decimal,no letters)" New topic
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)
 
Threads others viewed
validation for alpha letters using mask
WA #1.....word association
Regular Expression in JAVA for Checking whether a String contains Alphabet.
only upper case in input field
free marker template bug in displaying spanish accented characters correct case
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture