473,395 Members | 1,583 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,395 software developers and data experts.

Script correction for validating email text field

Hi,
Can anyone make me understand in JavaScript what is all which are in bold, I need simple function to validate a text-field on a form that is to hold an email address. The below in bold is complex for me to understand. Please make correction or provide new function.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">    
  2.  
  3.         function validateEmail(Form) 
  4.         {
  5.         if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Form.emailAddr.value))
  6.         {
  7.         alert("Valid Email Address");
  8.         return (true)
  9.         }
  10.         alert("Invalid E-mail Address!")
  11.         return (false)
  12.         }  
  13.     //-->
  14.     </script>
Mar 3 '10 #1
2 2692
Dormilich
8,658 Expert Mod 8TB
that’s one of the simpler email RegExp that the input is tested against
Mar 3 '10 #2
Thanks for the reply, i hope that is Javascript right? i found script from w3school as follows
What is the difference between the earlier one and this one,
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function validate_email(field,alerttxt)
  3. {
  4. with (field)
  5.   {
  6.   apos=value.indexOf("@");
  7.   dotpos=value.lastIndexOf(".");
  8.   if (apos<1||dotpos-apos<2)
  9.     {alert(alerttxt);return false;}
  10.   else {return true;}
  11.   }
  12. }
  13.  
  14. function validate_form(thisform)
  15. {
  16. with (thisform)
  17.   {
  18.   if (validate_email(email,"Not a valid e-mail address!")==false)
  19.     {email.focus();return false;}
  20.   }
  21. }
  22. </script>
  23. </head>
  24.  
Mar 3 '10 #3

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

Similar topics

2
by: Web Master | last post by:
Hi, I am having a little issue with Jacks Form mail php script. I have installed it and configured the form to get it to work, but for some bizarre reason I have 2 issues I can't seem to debug....
5
by: Mike | last post by:
I'm using a script provided by e-mailanywhere, it's a little too big for me. There's 1 text field and 1 password field in a form. OnSubmit, I would like both fields to be validated to look for...
30
by: Toni Mcintyre | last post by:
i'm having 2 problems with the http://validator.w3.org 1. if i have: <meta http-equiv="Content-Script-Type" content="text/javascript"> then why do i need <script type=text/javascript>...
10
by: Samir | last post by:
Say I have 4 forms, all four have different numbers of text boxes. is there a script that I can use to check to make sure everything on the form is not blank?
4
by: Semi Head | last post by:
Hello folks, I'm looking for a script to validate a specific number value in a standard form input field. An example would be, if someone enters a number into a form input, I want the script to...
7
by: Ray | last post by:
Hi all, I'm new to JavaScript and am trying to create a client side JavaScript form validation script. I'm doing ok with validating text input boxes but have a problem that I have not been able...
1
by: Stephen Adam | last post by:
Hi there people, I'm creating my own set of self validating text boxes. They all inherit from a base text box which simply contains a required field validator, they then usuallly implement...
3
by: Water Cooler v2 | last post by:
Questions: 1. Can there be more than a single script block in a given HEAD tag? 2. Can there be more than a single script block in a given BODY tag? To test, I tried the following code. None...
4
by: thanos | last post by:
Hello, I'm relatively new to PHP so I found this free contact us script on the net that i was going to use for my Contact Us php page. Its works pretty good except for error handling. I was...
51
by: Ojas | last post by:
Hi!, I just out of curiosity want to know how top detect the client side application under which the script is getting run. I mean to ask the how to know whether the script is running under...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.