Solved

validate single checkbox

Posted on 2004-08-06
3
380 Views
Last Modified: 2012-08-13
Hello expert,

I have one checkbox which is I agree.  I want to user to check I agree check box and then submit.  If the box is not check then an alert popup tell (you must accept agreement in order to submit application) thanks for yours help
0
Comment
Question by:princeofem
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
justinbillig earned 125 total points
Comment Utility
function SubmitApplication( )
{
if( formname.checkboxname.checked == true )
{
    formname.submit( );
}
else
{
    alert( "You must agree to submit the application." );
}
}


change your submit button type from submit to button and put that function in the onclick event .... or you could do this


function SubmitApplication( )
{
if( document.getElementById( "idofCheckbox" ).checked == true )
{
    formname.submit( );
}
else
{
    alert( "You must agree to submit the application." );
}
}


the first one works but sometimes browsers get funny and accessesing an elemeny by its id is supported by all browsers
0
 

Author Comment

by:princeofem
Comment Utility
function isIAgreement() {
if (document.form1.IAgreement.value == "") {
alert ("\n Please select tax preparer agreement")
document.form1.IAgreement.focus();
return false;
}
return true;
}

this is what i have...Can i modify to work with checkbox? thanks
0
 

Author Comment

by:princeofem
Comment Utility
Opp I have changed value to checked and it works :-) thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

743 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

14 Experts available now in Live!

Get 1:1 Help Now