Solved

Auto Check a checkbox when user begins typing in textbox

Posted on 2003-11-18
5
359 Views
Last Modified: 2006-11-17
I have a checkbox sitting next to a textbox.  The checkbox tells the form that there is valid information in the textbox.

What I need is if the user begins typing in the textbox without checking the checkbox, the checkbox should automatically become checked.

Sounds easy, but form field manipulation syntax confuses me.

Also, does anyone know of a website where I can learn more about javascript manipulation of form fields?

Thanks in advance.
0
Comment
Question by:ddotson
  • 2
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
Bustarooms earned 50 total points
ID: 9773122
<input type="textbox" name="myTextbox" onkeyup="this.form.theCheckbox.checked=(this.value != '')?true:false;"><br>
<input type="checkbox" name="theCheckbox">
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9773267
you could do without the checkboxes and just do some client siode javascript form validation
0
 

Author Comment

by:ddotson
ID: 9773548
That's true; however, the checkboxes are in use elsewhere in the form, and it is sort of a visual cue more than anything.

I tried Bustaroom's code, but it didn't work.  Here is what I have:

<input type = 'checkbox' name = 'otherEmail' value = 'yes'>
Other: <input type = 'text' name = 'otherEmailText' size = '35' onkeyup='this.form.otherEmail.checked=(this.value != '')?true:false;'>

BTW I am using it in ASP, hence the single quotes.
0
 
LVL 10

Expert Comment

by:Bustarooms
ID: 9773563
then you will need double quotes in the js part

<input type = 'text' name = 'otherEmailText' size = '35' onkeyup='this.form.otherEmail.checked=(this.value != "")?true:false;'>
0
 

Author Comment

by:ddotson
ID: 9773707
That got it.  Thanks-
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

932 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

12 Experts available now in Live!

Get 1:1 Help Now