473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Complete validations for email id

Hello
I am going through the validations in a form
I would like to know the validations to be considered in writing javascript for email id
so would u plz help me in writing the necessary functions
thanq

This is the code for that:


<html>
<head>
</head>
<body>
Email Id:
<input type="text"><br>
<input type="button" value="submit">
</body>
</html>
Apr 6 '07 #1
2 1565
mrhoo
428 256MB
To catch common typing errors, check the field for the basics.
/^[a-z]\w+@[a-z][^\.]+\.[a-z]\w+$/i
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>email</title>
  4. <script type="text/javascript">
  5. function valEmail(){
  6.     var who=document.getElementsByName('emailIn')[0];
  7.     var what= who.value;
  8.     if(/^[a-z]\w+@[a-z][^\.]+\.[a-z]\w+$/i.test(what))return form.submit();
  9.     else{
  10.         var pa=who.parentNode;
  11.         pa.firstChild.data="Valid Email Required:";
  12.         pa.style.backgroundColor='red';
  13.         pa.style.color="white";
  14.         who.focus();
  15.         who.select();        
  16.     }
  17.     return false;
  18. }
  19. onload=function(){
  20.     document.forms[0].onsubmit=function(){return valEmail()};
  21. }
  22. </script>
  23. </head>
  24. <body>
  25. <form action='' method='' >
  26. <p>
  27. <lable style="padding:1ex" >Email Id: 
  28. <input type="text" name="emailIn" value="" ></label>
  29. <input type="submit" value="Submit" >
  30. </p>
  31. </form>
  32. </body>
  33. </html>
Apr 6 '07 #2
mrhoo
428 256MB
Sorry- edit this line:(form should be form[0]);

if(/^[a-z]\w+@[a-z][^\.]+\.[a-z]\w+$/i.test(what))return form[0].submit();
Apr 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Naresh Agarwal | last post by:
Hi I'm using SAX Parser of Xerces Java v2.4.0 for XML Parsing. I want to perform schema validations on the xml. The problem is that root element of XML document does not have...
19
by: Gérard Talbot | last post by:
posted to: alt.html and comp.infosystems.www.authoring.html followup-to: comp.infosystems.www.authoring.html Hello all, I have 2 questions about validations. 1- What's basically the...
5
by: Gary Smith | last post by:
In my ASP.Net application I am using textbox for user to enter the date. How to enforce the user to enter only the numeric values( and "/" character) in this edit box ? Thanks for your...
1
by: Murat YILMAZ | last post by:
Hi all, I have develop a web page and there are 4 textbox on it. I have put 4 validation for these. Issue is that If I have request this page and submit form validations are not working. But I...
1
by: anil kumar via .NET 247 | last post by:
(Type your message here) hi, i am using save & cancel webform buttons in my webpage to withsome validations , when i am trying to save my content it issaved that time i need a popup msg like ur...
1
by: Anup | last post by:
In my form I and doing validations using 'Javascript' as I m using ASP1.1 and there is very less support for Validators there. //Code Behind private void Page_Load(object sender,...
1
by: harishkumar | last post by:
hi this is hari how to write the email id checking in javascript validations using in vb.net 1) if u r cecking in email id this types of message to delever to user a)(.) dot is missing b) two @...
7
by: php newbie | last post by:
I am creating a form Form1.php that posts to the another form Form2.php. I have input validations on the first form. I need the user to go to the next form ONLY if the inputs from the user are...
5
by: psrivani4 | last post by:
I want how to validate more than one email id in javascript in composemail for TO,CC fields.Please send it to my mail id Iam waiting for ur reply. Byeeeee.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.