473,499 Members | 1,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to link to a different page

1 New Member
I'm using this coding to have someone enter text; if they have not entered anything when the click the button they get an alert box asking for some input.
What I want is to send them to a New web page once they have actually entered something.

I have tried <a href....but it appears on the page; I don't want that. I just want an automatic change to the new page after the button has been pressed and a valid input has been made.
---------------------------
Expand|Select|Wrap|Line Numbers
  1.    <script type = "text/javascript">
  2.       function validate(){
  3.         // get inputs
  4.         name = document.getElementById("txtName").value;
  5.  
  6.         //create an empty error message
  7.         errors = "";
  8.  
  9.         //check name - It simply needs to exist
  10.         if (name == ""){
  11.           errors += "Please supply an answer…….. \n";
  12.     } 
  13.  
  14.         //end if               
  15.           //check for errors
  16.             if (errors == ""){
  17.  
  18.           //process the form
  19.         } else {
  20.          alert(errors);
  21.         }    // end if  
  22.       } // end function
  23.     </script> </head> <body> <h1>Frame...</h1> <h3><center>Mary had a _________ whose fleece was white as _______</h3> <form action = "http://example.com/"> <fieldset> <label>Name</label> <input type = "text" 
  24.     size=75S%
  25.                value = ""
  26.                id = "txtName" /> <button type = "button"
  27.                 onclick = "validate()">Check Your Answer </button>;
  28.  
  29.      </fieldset>
Mar 17 '13 #1
1 1395
Dormilich
8,658 Recognized Expert Moderator Expert
change the button type to "submit" and make sure, that when the validation fails, the default action (the form submit) is cancelled.

alternately, call the form’s submit() method in JS.
Mar 17 '13 #2

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

Similar topics

3
2553
by: Itai | last post by:
I have an aspx file named index.aspx which contains two ‘form' sections, one that has the runat=server attribute (e.g From1) and one which is a regular HTML form (e.g SignInForm). I am trying...
3
1526
by: js5895 | last post by:
Hi, Where can I find a free link and page counter for my web site, it's road runner, so basically theres no server-side functionality, lol Thanks. Note: If this is the wrong group for this...
6
2396
by: Shawn | last post by:
Any ideas how I can have a button click on one open page force a postback on a different page.
2
4351
by: Otto Wyss | last post by:
On a page of mine a user might submit data several time, which adds an entry to the history each time (similar as http://www.google.com/trends?q=iPod%2C+iPhone&ctab=0&geo=all&date=all). Yet later...
1
1771
by: bb nicole | last post by:
Below is my interface for resume which need to post into database... I have did it all in one page and it already can send into database which the table name resume... But my letturer now want me...
5
5691
by: Simon Benson | last post by:
Probably a fairly simple problem but one that's been plaguing me for a couple of days... can anyone help? I have a classic ASP page with a number of text boxes which are updatable. For...
1
1318
by: James97212 | last post by:
I’m trying to request a different page using VB with ASP. I can do this with Radio Buttons and a Dropdown Box. How do I setup the “RedirectPage” for a stand alone redirect? I'm using it in the...
8
2449
by: wish | last post by:
Dear all, I would to ask that why the user always faced the different page when user click the back button instead back to page2.php but it go to page5.php..I remember in asp, we use the...
2
1263
by: chainfire316 | last post by:
Hi, I am trying to find a script that automatically updates and lets my viewers know when a page was last updated but I want it to display on a different page then the one that is updating. Can...
0
7229
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...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
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...
0
5485
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,...
1
4921
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...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
311
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...

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.