Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Web
Expertise: Intermediate
Jul 27, 1999



Application Security Testing: An Integral Part of DevOps

Verify a Check Box Using JavaScript

It is possible to see if a check box has been checked or not in JavaScript. This may come in handy during form validation. A check box has a checked property, which returns either a 0 for not checked and a 1 for checked. You can also set the property to 0 or 1 to programmatically control the check box.

<script language=javascript>
function validate(chk){
  if (chk.checked == 1)
    alert("Thank You");
    alert("You didn't check it! Let me check it for you.")
    chk.checked = 1; 
<input type=checkbox name=chk1>Please Check Me
<p><input type=button value="check" onclick="return validate(chk1);">
William Wen
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date