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

Validate Email by Javascript then link to next page

28
I have 2 page:
index.aspx
next.aspx
and the code in javascript to validate Email:
Expand|Select|Wrap|Line Numbers
  1. function fnEmail() 
  2.         {     
  3.             if(checkEmail(form1.txtEmail.value)== false) 
  4.             {
  5.                 alert("Email is not valid!");
  6.                 form1.txtEmail.focus();
  7.                 return false;
  8.             } 
  9.             return true; 
  10.         } 
  11.          function checkEmail(mail)
  12.         {
  13.             mail = trim(mail);
  14.             var re=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,4}$/
  15.             if(mail.match(re) == null)
  16.                 return false;
  17.             return true;
  18.         }
  19.         function trim(sString) 
  20.         {
  21.             while (sString.substring(0,1) == ' ') 
  22.             {
  23.                 sString = sString.substring(1, sString.length);
  24.             }
  25.             while (sString.substring(sString.length-1, sString.length) == ' ')
  26.             {
  27.                 sString = sString.substring(0,sString.length-1);
  28.             }
  29.             return sString;
  30.         }
  31.  
  32. and the <input>:
  33. <a id="linknext" href="next.html"><input type="button" onclick="return         fnEmail();" class="NextButton" width="56" height="27"
  34.                                                                                     style="WIDTH: 56px; HEIGHT: 27px"> </a>
When you click in button, I want to test email valid then link to next.aspx page,
but It's not test validate and link to next.aspx? I don't know why and how to fix this bug.
Can you help me for the purpose: testing email and link to next.aspx page?.
Thanks
Jan 10 '08 #1
4 1678
kenobewan
4,871 Expert 4TB
Here is an example that may help:
JavaScript RegExp Example: Regular Expression Tester
Jan 10 '08 #2
thupham
28
Thanks for your reply but the link before is only submit the content and not link to next page. You can see in example before, the <input> tag was nested in <a> tag:
<a href="next.aspx"><input type="submit" onclick="return fnEmail()"></input></a> Can you search more web you know about this problem for me?.
Thanks.
Jan 11 '08 #3
CyberSoftHari
487 Expert 256MB
Subscribing …
Jan 11 '08 #4
kunal pawar
297 100+
Modify ur Code, this will hepl you

function fnEmail()
{
if(checkEmail(form1.txtEmail.value)== false)
{
alert("Email is not valid!");
form1.txtEmail.focus();
return false;
}
document.form Name.action="next.html";
document.submit();
return true;
}
function checkEmail(mail)
{
mail = trim(mail);
var re=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,4}$/
if(mail.match(re) == null)
return false;
return true;
}
function trim(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}

and the <input>:
<input type="button" onclick="return fnEmail();" class="NextButton" width="56" height="27"
style="WIDTH: 56px; HEIGHT: 27px">
Jan 11 '08 #5

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

Similar topics

5
by: Carl Gilbert | last post by:
Hi I have some ASP code that I want to run from CD within a VB.NET windows application with a web browser control. However, to get the ASP pages to run without a server is proving quite...
11
by: TokyoJ | last post by:
I run a small camp in Alaska for kids and my director is asking for a web form. Could someone please have a look and offer some advice on where I'm making mistake(s)? I'm using the RegExp function...
1
by: SkipNRun | last post by:
I am a novice when comes to JavaScript, AJAX. I am working on a form, which will allow users to update their contact information. In order to make the form flexible, I need to use pull down list. ...
5
by: Ganesh | last post by:
Hi There, I need to validate email address with regular expression control, i tried something like this ^+*@*\.*$ but i need to validate even if it is blank, it should say invalid email,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.