N/APosted on - 08/29/2011
I am a PHP web developer. I get some troubles using regular expressions for the form validation. It submits the form without validating the it.
The first problem I noticed is that you don't need so many functions to validate the page at all. I am providing you a sample form page and script which you can test and then modify for use according to your need. And it will work fine.
Paste this code in a sample HTML file and then save it and open on the browser to see the effects. Copy complete code and make sure that you are using a blank HTML file to paste this code, since it has headers and everything.
I hope it will function perfectly for you too, if you still face a problem making it on your own, I will write one for you.
Validation with java script is remains perfect concept and coding. Here I am giving an example in my style. You have to use it in your own style.
1. Required fields:
if (x==null || x=="")
alert("First name must be filled out");
2. Email validation:
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
alert("Not a valid e-mail address");