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

My functions not working!!!

41
Hi, Can some one help me? I dont know why my checkEmail function is not working, it gives errors.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Registration Details</title>
  3. <SCRIPT LANGUAGE="JavaScript">
  4.  
  5.  
  6.  
  7. /**
  8.  
  9.  
  10. function processForm1() {
  11. var form1 = document.formOne;
  12.  if (form1.firstname.value==""){
  13.  alert("you must fill in your first name")
  14.  formOne.firstname.focus();
  15.  }
  16.  else if (form1.lastname.value==""){
  17.  alert("you must fill in your lastname")
  18.  formOne.lastname.focus();
  19.  }
  20.  else if (form1.postcode.value==""){
  21.  alert("you must fill in your postcode")
  22.  formOne.postcode.focus();
  23.  }
  24.  else if (form1.dateofbirth.value==""){
  25.  alert("you must fill in your DOB")
  26.  formOne.dateofbirth.focus();
  27.  }
  28.  else if (form1.contactphonenumber.value==""){
  29.  alert("you must fill in your phone number")
  30.  formOne.contactphonenumber.focus();
  31.  }
  32.  
  33.   else if (form1.emailaddress.value==""){
  34.  alert("you must fill in your email address")
  35.  formOne.emailaddress.focus();
  36.  }
  37.  
  38.  
  39.  
  40.  else { 
  41.     controlForm = parent.frame2.document.controlForm
  42.     controlForm.firstname.value=form1.firstname.value
  43.     controlForm.lastname.value=form1.lastname.value
  44.     controlForm.address.value=form1.address.value
  45.     controlForm.city.value=form1.city.value
  46.     controlForm.county.value=form1.county.value
  47.     controlForm.postcode.value=form1.postcode.value
  48.     controlForm.country.value=form1.country.value
  49.     controlForm.contactphonenumber.value=form1.contactphonenumber.value
  50.     controlForm.dateofbirth.value=form1.dateofbirth.value
  51.     controlForm.emailaddress.value=form1.emailaddress.value
  52.     controlForm.mypassword.value=form1.mypassword.value
  53.     location.href="login.html"
  54.  
  55. }
  56.  
  57. }**/
  58.  
  59. function checkEmail() {
  60. var emailFilter=/^/w+([/.-]?/w+)*@;
  61.   if(emailFilter.test(document.form1.emailaddress))
  62. return true
  63. else{
  64. alert(“invalid email address”)
  65.  formOne.emailaddress.focus();
  66. }
  67.  
  68.  }
  69.  
  70.  
  71.  
  72.  
  73. </script>
  74. </head>
  75.  
  76. <body>
  77. <form method="GET" action="http://localhost:8081/controlform.html" NAME="formOne"    >
  78.  
  79. <center>
  80. <h1>Registration Details</h1>
  81. <br><br>
  82. First Name <input type="text" name="firstname" value=""><br><br>
  83. Last Name <input type="text" name="lastname" value=""><br><br>
  84. Address <input type="text" name="address" value=""><br><br>
  85. City <input type="text" name="city" value=""><br><br>
  86. County (optional) <input type="text" name="county" value=""><br><br>
  87. Post Code <input type="text" name="postcode" value=""><br><br>
  88. Country <input type="text" name="country" value=""><br><br>
  89. Contact Phone Number <input type="text" name="contactphonenumber" value=""><br><br>
  90. Date of Birth <input type="text" name="dateofbirth" value=""><br><br>
  91. Email Address <input type="text" name="emailaddress" value=""><br><br>
  92. Password (minimum 6 characters) <INPUT TYPE=PASSWORD NAME="mypassword"><br><br>
  93. <input type="BUTTON" NAME="Submit"  value="--SUBMIT--" onClick="checkEmail()">
  94. </center>
  95. </form>
  96. </body>
  97. </html> 
  98.  
  99.  
Mar 5 '07 #1
4 1132
iam_clint
1,208 Expert 1GB
if(emailFilter.test(document.form1.emailaddress))

needs to be

if(emailFilter.test(document.formOne.emailaddress) )


.test isn't anything so figure out what your problem is there


and your regular expression isn't declared as a regular expression.

and its not correct.
Mar 5 '07 #2
Naha
41
ok, i have created the function checkemail2, and its also giving me errors.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head><title>Registration Details</title>
  3. <SCRIPT LANGUAGE="JavaScript">
  4.  
  5.  
  6.  
  7. /**
  8.  
  9.  
  10. function processForm1() {
  11. var form1 = document.formOne;
  12.  if (form1.firstname.value==""){
  13.  alert("you must fill in your first name")
  14.  formOne.firstname.focus();
  15.  }
  16.  else if (form1.lastname.value==""){
  17.  alert("you must fill in your lastname")
  18.  formOne.lastname.focus();
  19.  }
  20.  else if (form1.postcode.value==""){
  21.  alert("you must fill in your postcode")
  22.  formOne.postcode.focus();
  23.  }
  24.  else if (form1.dateofbirth.value==""){
  25.  alert("you must fill in your DOB")
  26.  formOne.dateofbirth.focus();
  27.  }
  28.  else if (form1.contactphonenumber.value==""){
  29.  alert("you must fill in your phone number")
  30.  formOne.contactphonenumber.focus();
  31.  }
  32.  
  33.   else if (form1.emailaddress.value==""){
  34.  alert("you must fill in your email address")
  35.  formOne.emailaddress.focus();
  36.  }
  37.  
  38.  
  39.  
  40.  else { 
  41.     controlForm = parent.frame2.document.controlForm
  42.     controlForm.firstname.value=form1.firstname.value
  43.     controlForm.lastname.value=form1.lastname.value
  44.     controlForm.address.value=form1.address.value
  45.     controlForm.city.value=form1.city.value
  46.     controlForm.county.value=form1.county.value
  47.     controlForm.postcode.value=form1.postcode.value
  48.     controlForm.country.value=form1.country.value
  49.     controlForm.contactphonenumber.value=form1.contactphonenumber.value
  50.     controlForm.dateofbirth.value=form1.dateofbirth.value
  51.     controlForm.emailaddress.value=form1.emailaddress.value
  52.     controlForm.mypassword.value=form1.mypassword.value
  53.     location.href="login.html"
  54.  
  55. }
  56.  
  57. }
  58.  
  59. function checkEmail() {
  60. var form1 = document.formOne;
  61. var emailFilter=/^/+w([/.-]?/+w)*@$/;
  62.   if(emailFilter.test(document.form1.emailaddress))
  63. return true
  64. else{
  65. alert(“invalid email address”)
  66.  formOne.emailaddress.focus();
  67. }
  68.  
  69.  }**/
  70.  
  71.  
  72.  function checkEmail2() {
  73.  var error = "";
  74.  var form1 = document.formOne;
  75.  var emailFilter=/^.+@.+\..{2,3,4,6}$/;
  76.  var email= form1.emailaddress.value;
  77. if (!(emailFilter.test(email)))  {
  78.        error = "Invalid email!\n";
  79.     }
  80. return error;   
  81.  }
  82.  
  83.  
  84. </script>
  85. </head>
  86.  
  87. <body>
  88. <form method="GET" action="http://localhost:8081/controlform.html" NAME="formOne"    >
  89.  
  90. <center>
  91. <h1>Registration Details</h1>
  92. <br><br>
  93. First Name <input type="text" name="firstname" value=""><br><br>
  94. Last Name <input type="text" name="lastname" value=""><br><br>
  95. Address <input type="text" name="address" value=""><br><br>
  96. City <input type="text" name="city" value=""><br><br>
  97. County (optional) <input type="text" name="county" value=""><br><br>
  98. Post Code <input type="text" name="postcode" value=""><br><br>
  99. Country <input type="text" name="country" value=""><br><br>
  100. Contact Phone Number <input type="text" name="contactphonenumber" value=""><br><br>
  101. Date of Birth <input type="text" name="dateofbirth" value=""><br><br>
  102. Email Address <input type="text" name="emailaddress" value=""><br><br>
  103. Password (minimum 6 characters) <INPUT TYPE=PASSWORD NAME="mypassword"><br><br>
  104. <input type="BUTTON" NAME="Submit"  value="--SUBMIT--" onClick="checkEmail2()">
  105. </center>
  106. </form>
  107. </body>
  108. </html> 
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
Mar 5 '07 #3
acoder
16,027 Expert Mod 8TB
See this page for info. on regular expressions. Your slashes are wrong and you haven't defined it properly.
Mar 5 '07 #4
acoder
16,027 Expert Mod 8TB
Aah, we both posted at the same time - didn't realise.

Again, I reiterate, your email regular expression is incorrect.

Try using something like:
Expand|Select|Wrap|Line Numbers
  1. /^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/
(adapted from the link I gave you).

Also, you have commented out all your functions!!
Mar 6 '07 #5

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

Similar topics

4
by: David Walker | last post by:
Hi again As I'm developing my site, i've come across a problem with the database use. While developing it I only have mySQL, but the final server has msSQL. I was thinking about using all my own...
12
by: Kay Schluehr | last post by:
Hi all, thanks for Your attention ! I think my proposal was more in mind of Rons modified exec than Pythons lambda. When George proposed his unpacking behavoir for list-comps as a pack of...
25
by: Stijn Oude Brunink | last post by:
Hello, I have the following trade off to make: A base class with 2 virtual functions would be realy helpfull for the problem I'm working on. Still though the functions that my program will use...
5
by: Matt | last post by:
I am working in a project where the business model is complex enough that many common retrieval functions become difficult to develop and maintain in single query statements or functions. I have...
1
by: PTS | last post by:
I am working on a program that will calculate some numbers. As an example, I will say student average test score and print out the grade but my question is how do I put AVERAGE and test score and...
3
by: Torch | last post by:
I have some javascript that has been working for a year - I have just upgraded to IE6 and now its stopped working. The page consists of a parent window containing some functions and an iframe...
1
by: Quentin Huo | last post by:
Hi: I have several classes and they have some same common functions like write a property value to a text file, or read from the file to a property. I did as followed: I created an abstract...
8
by: herman | last post by:
Hi ... We are running v7.1 on Linux Redhat 7.2 All things were fine, until the power supply of the box fried after 4 years of un-interrupted service (2 reboots only) Replaced the power supply, and...
4
by: David | last post by:
Hi, I have taken some SQL from MS Access and got it working. I have since updated the SQL in Access but cannot get the additional part working in ASP. The working SQL I have in asp is:- ...
20
by: J de Boyne Pollard | last post by:
MThe library functions which are included to allow process Mlaunch, forking, and termination, imply that it is both Mpossible and desirable for a process to fork itself. This is Ma fundamental...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.