![]() |
Form validation with Regex [Prototype]
How to validate forms, through regex, with javascript (if framework, prototype)?
|
That's rather vague Haris, could you be a bit more specific? Are you trying to validate an email address or something?
|
I'm trying to validate a URL. The most convenient options looks like regex. After a little bit of research, I found Formassembly w3forms convenient javascript validation script.
It supports a bit of validation functions itself ad it supports validating data through regex. I would like to ask that with javascript validation, should I also use server-side validation (I.E with PHP) since someone can easily modify js through firefox. |
you always use server side validation.
Always always always. JavaScript validation is only a convenient way to the user to fix their problems before they have to submit. But ultimately, it doesn't count for anything legit. Also, a lot of bots won't even pick up the javascript, so someone could just as easily spam your site with false information. |
|
I dont think im the best qualified for giving this solution but i have created this pattern and although it is not perfect as it is It may give you a starting point for what you are trying to achieve.
Validate URL: /^(http|https|ftp):\/\/([\w]*)\.([\w]*)\.(com|net|org|biz|info|mobi|us|cc|bz|tv|ws|name |co|me)(\.[a-z]{1,3})?$/iExample: PHP Code:
|
I been playing a bit with prototype and thought of giving this a try, im sure it can be improved but anyways here it is, i hope it helps:
HTML Code:
<script src="prototype.js" type="text/javascript"></script> |
Quote:
Please consider FormAssembly's wForms javascript extension. |
| All times are GMT. The time now is 07:08 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0