473,624 Members | 2,394 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 1402
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
2566
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 to copy values from two INPUT controls that are located within the Form1 section to hidden INPUT controls located in the SignInForm and post the SignInForm form hidden controls values to a different page (e.g login.aspx) Problem is that after...
3
1534
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 message, could you please redirect me, thanks and sorry.
6
2404
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
4405
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 the user wants to go back to the previous page in one step. Now is it possible to loop backwards through the history until a different page is reached? Has anybody coded something like this? O. Wyss --
1
1781
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 to seperate it in to 4 pages( 1 page is for personnel particular, 1 page is for education, 1 page is for worl experience and so on). And it is need a next button to continue it, at last user need to click on post resume button and post to database....
5
5698
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 convenience I want to add 'tabs' at the top of the page (like a card index) as the data to be displayed is split into specific groups (client, company, preferences, events). How do I update any changes to the data and switch to a different page - at
1
1324
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 following condition statment: <% If Condition then Response.Redirect(Request.Form("RedirectPage"))
8
2465
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 global.asa to solve this problem because the server will confuse when many user login the system as a member and every members go different pages. So may i have anyone to guide me?
2
1268
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 anyone help me do this? Thanks.
0
8625
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
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
7168
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...
0
5565
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
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2610
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 we have to send another system
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
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.