I have 2 page:
index.aspx
next.aspx
and the code in javascript to validate Email: - function fnEmail()
-
{
-
if(checkEmail(form1.txtEmail.value)== false)
-
{
-
alert("Email is not valid!");
-
form1.txtEmail.focus();
-
return false;
-
}
-
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>:
-
<a id="linknext" href="next.html"><input type="button" onclick="return fnEmail();" class="NextButton" width="56" height="27"
-
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
4 1747
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.
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">
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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...
|
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...
|
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
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |