| HTML/XHTML Design Discuss anything to do with HTML XHTML design here. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
Okay, I'm making a form for an HTML class. It is an online class that I am taking. I have to validate my form. I think I got almost everything I need. But, one aspect is giving me trouble. How do I control what people enter in the fields? For example, how do I get people to only enter numerals in a zip code field instead of letters? Also, how do I make sure people enter an actual email address instead of just random characters? Thanks.
|
|
|||
This is beyond HTML, you will probably need to use some javascript with this. I'm just learning it right now so I can't share much in terms of actual coding, but the following would be good philosophical rules to check against.A workable zip code is composed of five numeral digits, 0-9. If the inputted text is longer than 5 characters or contains any alphabet or special characters, you can reject the entry.Every e-mail address is of the form x@y.z . You can check to make sure the inputted text contains an @ character, and even add the condition to check for a period somewhere after the @.You can run a check immediately after text is entered into a form by using an onChange event handler in your HTML code:In this case, the function checkZip would execute after the zip input is changed by the user. In writing this function, you could easily implement the rules I listed above to either accept or reject the entry.
|
![]() |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
All times are GMT. The time now is 02:05 PM.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
Ad Management by RedTyger





Linear Mode
