You could attach an onkeyup event to the input that triggers a function every time a key is released in the input. The function could be just a regular expression that replaces the value of the input with any unwanted extra + characters removed.
Without being more specific on the regular expression, I'm not sure how to do it using one.
You can loop through each character of the input string and check the character with a charAt function. Keep track if you have one or more + or - signs, if more than one, alert the user to remove them.
I have this as my onkeyup function. So you say a loop to it?
function clearChar() {
document.adjustment.adjustAmount.value=filterNum(document.adjustment.adjustAmount.value)
function filterNum(str) {
re = /[^0-9.+-}]/g
return str.replace(re, "");
}
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.