Validating text boxes in javascript

Client side validation is performed by a web browser, before input is sent to a web server.

my qestion is how can i pass a text box(NOT THE VALUE OF TEXTBOX) to a function so that i don't have to right document.getelementby ID for every text box.

You are currently viewing the BOOK: Beginning Java Script section of the Wrox Programmer to Programmer discussions.

validating text boxes in javascript-84validating text boxes in javascript-4validating text boxes in javascript-42

So the condition is we check whether the textbox contains anything ELSE other than numbers and display a message As you can see the function validate() checks if the entered string contains characters that does NOT (notice the ^ symbol) match the numbers 0 to 9 including white spaces and special characters.

Reg Exp for basic javascript validation read Javascript Validation – Textbox Combobox Radiobutton Checkbox.

Using regular expressions the entered content can be validated with advanced conditions like the string entered shouldn’t contain spaces, special characters, numbers, uppercase or lowercase etc.

gets the runtime generated ID which is different(not always) from server side ID.

I have an Text Box control on my page and a search button whenever user clicks on the search button i want to validate the Text Box for Blank.

Leave a Reply