0

I used this code only numeric input but ^ char can input? How can i fix?

    <input type="text" onkeypress='return event.charCode >= 48 && event.charCode <= 57'></input>
2
  • 1
    Take a look at this: stackoverflow.com/questions/20115337/… Commented Nov 22, 2013 at 9:24
  • Your code works fine actually. Did you used some non-english input method? Commented Nov 23, 2013 at 0:05

1 Answer 1

1
<input type="text" onkeypress='return( event.charCode >= 48 && event.charCode <= 57) || (event.charCode==94) '></input>

This will solve your purpose

function validateInput(evt)
{
    if ((evt.charCode >= 48 && evt.charCode <= 57) || (evt.charCode==94))
        return true;
    else
        return false;
}

<input type="text" onkeypress='return validateInput(event)'></input>
Sign up to request clarification or add additional context in comments.

3 Comments

@sugar, if you think the answer helped, don't forget to mark it as correct.
I don't wanna put ^ except your code my code accept ^^^ I don't want.
your code does not seem to except the character (^) see jsfiddle.net/sahilthadhani/sCxCk/1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.