473,657 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validate Email by Javascript then link to next page

28 New Member
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 1747
kenobewan
4,871 Recognized Expert Specialist
Here is an example that may help:
JavaScript RegExp Example: Regular Expression Tester
Jan 10 '08 #2
thupham
28 New Member
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 Recognized Expert Contributor
Subscribing …
Jan 11 '08 #4
kunal pawar
297 Contributor
Modify ur Code, this will hepl you

function fnEmail()
{
if(checkEmail(f orm1.txtEmail.v alue)== false)
{
alert("Email is not valid!");
form1.txtEmail. focus();
return false;
}
document.form Name.action="ne xt.html";
document.submit ();
return true;
}
function checkEmail(mail )
{
mail = trim(mail);
var re=/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,4}$/
if(mail.match(r e) == null)
return false;
return true;
}
function trim(sString)
{
while (sString.substr ing(0,1) == ' ')
{
sString = sString.substri ng(1, sString.length) ;
}
while (sString.substr ing(sString.len gth-1, sString.length) == ' ')
{
sString = sString.substri ng(0,sString.le ngth-1);
}
return sString;
}

and the <input>:
<input type="button" onclick="return fnEmail();" class="NextButt on" 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
2235
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 difficult. I was thinking of converting the pages to use JavaScript but I know virtually no JavaScript and just wanted to check if what I want to achieve is possible before making any changes.
11
8159
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 to validate 3 types of fields: text, radio button, dropdown menu. but the code doesn't validate. After 2 days, it's time I asked for guidence. Criteria: Text: only alphabet, no numerals, allowed Radio: one must be selected, Dropdown: an option...
1
3988
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. Depends on the pull down list selection, I use script.aculo.us to validate the user input before submit and pass the necessary data, such as contact type, contact information and ranking to a php program for updating. This form should allow multiple...
5
1868
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, but don't want to use another requirefield validator
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7327
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.