How to verify text for numbers only in html?How to verify text for numbers only in html?
Using ONLY html, this is impossible as far as I know. You could do it easily in PHP by error catching.How to verify text for numbers only in html?
You can use javascript to verify it, search on search engine about javascript validation or use dreamweaver to have inbuilt number validation in the form
You can't.
HTML isn't a programming language, it's a markup language. And it has no markup for 'numbers only'.
You can add JavaScript to your HTML to do it. That's a good thing to do, but it still doesn't protect you 100%. Users might have JS disabled, or malicious users might change your JS code. So you need to test for numbers only on the server as well. So you need to be asking 2 questions:
How do I test for numbers only in JavaScript.
How do I test for numbers only in (PHP, ASP.NET, Java Applet, CGI, etc. INSERT YOUR SERVER SIDE TECHNOLOGY HERE) .
You do that in Javascript in the browser. (Don't send invalid data to the server for validation when you can validate it in the browser.) Either catch every onKeyPress (or onKeyDown) or just check the entire input in your normal form validation function.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment