Jump to content

Email Id Validation Script

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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...