By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,619 Members | 1,712 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,619 IT Pros & Developers. It's quick & easy.

Restrict MaxLength

P: 3
I put MaxLength of text box is "10". After entering "." it is not allowing more than 2numbers. How to restrict it?. Ex:- 10.34, After than it is not allowing any letters.
Jan 21 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

Use onkeypress and check each key pressed. If the dot key has been pressed, check that only two more number keys are pressed. To prevent a key being entered, just return false as shown in the example on the linked page.
Jan 21 '08 #2

P: 3
i cant get u. please replay clearly
Jan 24 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Before that, I think you should clearly explain the question properly.

Instead of restricting the maxlength, just restrict the key presses - see the linked page.
Jan 24 '08 #4

P: 3
After Enter "." it wont allow more than 2 characters. How to restrict that.
Jan 24 '08 #5

acoder
Expert Mod 15k+
P: 16,027
I'm not sure I understand what you mean. If it doesn't allow already then there's no need to restrict the input.

By restricting, it would mean not allowing.

I think it'd be better if you post what code you have so far then we can work from there.
Jan 24 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.