dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
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

WEBINAR:

On-Demand

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.

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

 

 

 

 

 


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

 

 

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