Solved

Form submit button inactive

Posted on 2006-07-15
2
2,975 Views
Last Modified: 2008-01-09
I have two forms. I would like to make the second forms submit button inactive if anything is typed into the first forms 'f_name' field.

How do I do that with Javascript?

<form name="form1" method="post" action="page.html">
  <input type="text" name="f_name">
  <input type="hidden" name="step" value="2">
  <input type="submit" value="Next">
</form>

<form name="form2" method="post" action="page.html">
  <input type="hidden" name="step" value="3">
  <input type="submit" value="Skip this step">
</form>
0
Comment
Question by:silver00x00
2 Comments
 
LVL 16

Accepted Solution

by:
Joe earned 125 total points
Comment Utility
<script language="JavaScript">
         function checkForButtonDisable(fname){
              if(fname.value.length > 0){
                 document.getElementById("skipButton").disabled = true;
              }else{
                   document.getElementById("skipButton").disabled = false;
             }
         }
</script>

<form name="form1" method="post" action="page.html">
  <input type="text" name="f_name" onchange="checkForButtonDisable(this);">
  <input type="hidden" name="step" value="2">
  <input type="submit" value="Next">
</form>

<form name="form2" method="post" action="page.html">
  <input type="hidden" name="step" value="3">
  <input type="submit" value="Skip this step" id="skipButton">
</form>
0
 

Author Comment

by:silver00x00
Comment Utility
thanks!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now