Solved

validate single checkbox

Posted on 2004-08-06
3
386 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
justinbillig earned 125 total points
ID: 11736342
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
ID: 11736400
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
ID: 11736429
Opp I have changed value to checked and it works :-) thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Table style position to the left 8 39
Building JSON/JQuery Results Display 11 53
XJS:  how to throw error if no match found 8 56
Change background images after 5 seconds. 12 46
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

734 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