Limiting type and length in a textbox
-
I have a web page where I need the user to enter a phone number and I have it divided into 3 boxes (I'm in the US) first 2 need 3 numbers and the last 4 digit It currently will accept anything and at any length, obviously not good for a phone number. Is there anyway to using ASP and VB.NET to limit the characters a text box will accept to numeric (without limiting the entire page) and limit how many characters the textbox will accept (again, not the entire page). I've tried putting code in the 'TextChanged' declaraction, but it never seemed to run. Any suggestions would be great. I don't trust the users to always enter the right info in the right places. The wisest of the wise may err. - Aeschylus Codito Ergo Sum
-
I have a web page where I need the user to enter a phone number and I have it divided into 3 boxes (I'm in the US) first 2 need 3 numbers and the last 4 digit It currently will accept anything and at any length, obviously not good for a phone number. Is there anyway to using ASP and VB.NET to limit the characters a text box will accept to numeric (without limiting the entire page) and limit how many characters the textbox will accept (again, not the entire page). I've tried putting code in the 'TextChanged' declaraction, but it never seemed to run. Any suggestions would be great. I don't trust the users to always enter the right info in the right places. The wisest of the wise may err. - Aeschylus Codito Ergo Sum
You can add normal HTML tags to a textbox, and htey will go through to the client. You can set a maximum length property this way, but I'm not sure about numbers, I think you need to use javascript to do this. The obvious solution is to add validators that run on the client side, but I agree that it's nicer to not let the user enter the wrong thing to start with. Christian Graus - Microsoft MVP - C++
-
I have a web page where I need the user to enter a phone number and I have it divided into 3 boxes (I'm in the US) first 2 need 3 numbers and the last 4 digit It currently will accept anything and at any length, obviously not good for a phone number. Is there anyway to using ASP and VB.NET to limit the characters a text box will accept to numeric (without limiting the entire page) and limit how many characters the textbox will accept (again, not the entire page). I've tried putting code in the 'TextChanged' declaraction, but it never seemed to run. Any suggestions would be great. I don't trust the users to always enter the right info in the right places. The wisest of the wise may err. - Aeschylus Codito Ergo Sum
Hi: Check out http://www.peterbailey.net/ for the fValidate JavaScript. It uses Rich RegEX for Phone validations. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/