Jump to content

Email Id Validation Script


subha rr
 Share

Recommended Posts

You should validate the email on the server, not the client. If you truly submit the form with JavaScript (AJAX style), it should be a snap to return an error back to JavaScript on failure or do something else on success.The means to validate the mail on the server vary depending on your server language of choise. In PHP, the easiest and most catch-all way of doing it is with the filter extension (built into PHP5), like so:

if (is_bool(filter_var('bob@example.com', FILTER_VALIDATE_EMAIL))) {//mail is invalid. Error handling goes here.}else {//mail is valid. Send the message from here}

Link to comment
Share on other sites

if you want to validate email id using javascript, use following function.It's working perfect.function validateEmail(email_id){ var emailId=email_id; var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i if (!filter.test(emailId)) { return false; else return true;}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...