Emtpy check box  validation in javascript

Friends I want to validate check boxes thru javascript,but I can do it if only one checkbox is there,but my requirement is to tell the page that it is alright even if one checkbox out of many is checked.Please tell me how to do it.
Thanks
MS
<SCRIPT>
function onSave() {
(document.TestJsp.BONUS.checked)?
alert("The box is checked"):
alert("The box is not checked")
</SCRIPT>
<TR>
<TD>
<INPUT TYPE="CHECKBOX" NAME ="BONUS" VALUE="1" >
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="CHECKBOX" NAME ="BONUS" VALUE="2" >
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="SUBMIT" NAME ="SUBMITBUTTON" VALUE="1" onClick="onSave()">
</TD>
</TR>

function validateCheckBox()
if(document.TestJsp.BONUS.checked)
return true;
var len = document.TestJsp.BONUS.length;
for(i = 0 ; i < len; i++)
if(document.TestJsp.BONUS.checked)
return true;
return false;
Sorry for the triple post. :=)

Similar Messages

  • Check box validation using Javascript

    Hi Everyone,
    I am using LiveCycle with my form that have multiple sections in the form that have questions that have a check box yes or  check box no next to it.  The user can either choose yes or no. Note: I am not using radio buttons.   I am looking for a Javascript function or code that when clicking a button I have set up as "regular" can check to see if a user selected either check boxes (yes) or check box (no) and validate that in that section the user has answered all question by selecting either yes or no.  Example; Section (1) has (5) questions with a yes or no check box next to each question.  I want to validate that the user selected 5 check boxes for this section (regardless if yes or no was answered for each)  if only 2 out od the 5 questions were answered with either yes or no.  I generate an error message. 
    I already have a function that searches the form and tells me how many manditory text fields have been left blank and throws an error.  I would like the check box function to be the same.  Any help would be appreciated.
    Thanks
    Jagan

    function validateCheckBox()
    if(document.TestJsp.BONUS.checked)
    return true;
    var len = document.TestJsp.BONUS.length;
    for(i = 0 ; i < len; i++)
    if(document.TestJsp.BONUS.checked)
    return true;
    return false;
    Sorry for the triple post. :=)

  • Check Box Validation in Offline Form

    Dear Experts,
    I have a requirement in an offline form where I have six check boxes, and out of the six check boxes
    user can only select any three.
    Request you to please suggest how to achieve this.
    Warm Regrads,
    Upendra Agrawal

    Thanks a ton Shaira.
    Full points to you
    Just wondering  what is the "Validation Script Message" for each UI.
    warm regards,
    Upendra Agrawal

  • Problem in check box validation

    Hi All
    I have designed a form in screen painter which contains the employee details.
    I have kept two check boxes MALE and FEMALE with itemuid as chmale and chfemale.
    I wont to do some validation.
    It is check box so I can check both of them,so I need to do validation
    My code
    Case SAPbouiCOM.BoEventTypes.et_CLICK
                                    Try
                                        Select Case pVal.ItemUID
                                            Case "chmale"
                                                oCheckFemale = oForm.Items.Item("chfemale").Specific
                                                If oCheckFemale.Checked = True Then
                                                    oCheckMale.Checked = True
                                                    oCheckFemale.Checked = False
                                                End If
                                            Case "chfemale"
                                                oCheckMale = oForm.Items.Item("chmale").Specific
                                                If oCheckMale.Checked = True Then
                                                   oCheckMale.Checked = False
                                                    oCheckFemale.Checked = True
                                                End If
                                        End Select
    This is not working.
    SAP hangs up for some time.

    Hi,
    You are missing with BubbleEvent=true;
    Below is My Code in C# and its working perfactly for the same requirement as yours.
    I have Done it on ItemClick BeforeAction
    oCheckBox1 = (SAPbouiCOM.CheckBox)oForm.Items.Item("4").Specific;
                    oCheckBox2 = (SAPbouiCOM.CheckBox)oForm.Items.Item("5").Specific;
                    if (pVal.ItemUID == "4" && oCheckBox1.Checked == false)
                        oCheckBox2.Checked = false;
                    if (pVal.ItemUID == "5" && oCheckBox2.Checked == false)
                        if (oCheckBox1.Checked == true)
                            oCheckBox1.Checked = false;

  • Check box validation

    Hello all,
    I need to perform validations on text field. I have two check boxes and by checking any one or both of them, a combination of text fields appear. I want to write four validations and one of them is shown below. I just have the basic idea, can anyone help me in writing it the correct way and what validation method(sql, item not null, regular exp, etc) to select?
    BEGIN
    IF(check box 1 is checked and check box 2 is unchecked) THEN
    :P3_TEXT_FIELD_1 := required;
    :P3_TEXT_FIELD_2 := required;
    :P3_TEXT_FIELD_3 := null;
    END IF;
    END;
    thanks,
    Toopran

    Hello,
    Thanks for the suggestion. I am having the validation of the type function returning error text and this is the actual code that I am using in my application.
    BEGIN
    IF :P11_WRITING_OBJ_FLAG IS NULL AND :P11_LAB_SCIENCE_FLAG IS NULL THEN
    :P11_NOTE_4 := NULL;
    :P11_NOTE_5 := NULL;
    :P11_NOTE_6 := NULL;
    :P11_NOTE_8 := NULL;
    IF :P11_NOTE_1 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_2 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_3 IS NULL THEN
    return 'enter a value in the text field';
    END IF;
    END IF;
    IF :P11_WRITING_OBJ_FLAG IS NOT NULL AND :P11_LAB_SCIENCE_FLAG IS NULL THEN
    :P11_NOTE_1 := NULL;
    :P11_NOTE_2 := NULL;
    :P11_NOTE_3 := NULL;
    :P11_NOTE_8 := NULL;
    IF :P11_NOTE_4 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_5 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_6 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_7 IS NULL THEN
    return 'enter a value in the text field';
    END IF;
    END IF;
    IF :P11_WRITING_OBJ_FLAG IS NULL AND :P11_LAB_SCIENCE_FLAG IS NOT NULL THEN
    :P11_NOTE_4 := NULL;
    :P11_NOTE_5 := NULL;
    :P11_NOTE_6 := NULL;
    :P11_NOTE_7 := NULL;
    IF :P11_NOTE_1 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_2 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_3 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_8 IS NULL THEN
    return 'enter a value in the text field';
    END IF;
    END IF;
    IF :P11_WRITING_OBJ_FLAG IS NOT NULL AND :P11_LAB_SCIENCE_FLAG IS NOT NULL THEN
    IF :P11_NOTE_1 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_2 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_3 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_4 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_5 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_6 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_7 IS NULL THEN
    return 'enter a value in the text field';
    ELSE IF :P11_NOTE_8 IS NULL THEN
    return 'enter a value in the text field';
    END IF;
    END IF;
    END;
    :P11_WRITING_OBJ_FLAG IS NULL and :P11_LAB_SCIENCE_FLAG are the check boxes and P11_NOTE_1 to P11_NOTE_8 are the 8 text fields that I want to validate based upon which box is checked.
    I am getting this error when I enter some values in the text field and click on SAVE button:
    ORA-06550: line 70, column 4: PLS-00103: Encountered the symbol ";" when expecting one of the following: if The symbol "if" was substituted for ";" to continue. ORA-06550: line 70, column 22: PLS-00103: Encountered the symbol ";" when expecting one of the following: if The symbol "if" was substituted for ";" to continue. ORA-06550: line 70, column 73: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: begin case declare end exit for goto if loop mod null pragm
         Error      ERR-1024 Unable to run "function body returning text" validation.
    Please help.
    thanks,
    Toopran

  • Checked box validation

    Hi All,
    I am using oracle Forms 10G on windows.
    I need help on how to validate that only one check box is checked in detail block. I have multiple records in the detail block and I have check boxes for each record in the detail block.
    I have a button to select the values from the detail records where the check box is checked. But I want to make sure that only one record is check not more than one.
    And How to move the cursor to the checked record if the focus or cursor is in an unchecked record.
    Thanks,

    One way would be to create a forms level variable (Global, Parameter item, Forms Package Specificaiton, etc) to record the record number of a checked record. Each time a user clicks a check box, you would check your variable to see if it is greater than 0. If its greater than zero then you know the user has already checked a check box and you know which record needs to be unchecked. Another option would be to just pop a message to the user to uncheck any checked records. I like the first option because it is more user friendly. Here is a code sample. I like using Forms Package spec variables because of they have a smaller memory footprint, but you can use a Block item, Parameter, Global, etc to record the record variable.
    /* Sample When-Checkbox-Changed trigger */
    DECLARE
       n_curr_record   NUMBER := 0;
    BEGIN
       IF ( Forms_Var.checked_record > 0 ) THEN
          n_curr_record := :system.trigger_record;
          /* Forms_VAR is a Forms Program Unit Package Specification */
          Go_Record(Forms_VAR.Checked_Record);
          :YOUR_BLOCK.YOUR_CHECKBOX_ITEM := 0;
          /* Assumes you are using 0 = unchecked and 1 = checked */
          Go_Record(n_curr_record);
          /* return to the current record */
       END IF;
    END;Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Agree to terms and conditions check box

    I am using a checkbox for users to indicate that they agree to the forms terms and conditions. On Submit how can I validate that the box was checked and if not block the Submit process from completing until the checkbox is selected.

    Make the submit button presence 'hidden', add a second button that performs the check box validation and if the validation succeeds, call 'click' on the submit button.
    // form1.page1.subform1.callSubmitBtn::click - (JavaScript, client)
    if (form1.page1.subform1.cb.rawValue == "0") {
       xfa.host.messageBox("Please agree to terms and conditions.","Agree",0);
    else {
       form1.page1.subform1.submitBtn.execEvent("click");
    Steve

  • Validating forms using check boxs

    hi i am trying to validate a form using check boxs where all of the elements have the same name. Using the code below it enables validation when only one check box is available, however with muliple check-boxs it goes into and eternal loop and never executes the code! Any help on this matter would be most appreciated.
    <SCRIPT language="javaScript">
    function validate()
    if (!document.myform.pkey.checked)
    alert("Please Select a Questionnaire to delete!!");
         return false;
    </SCRIPT>

    Hi,
    When you have multiple checkboxes with same name, it will form an array of check boxes. So you have to validate them as below.
    flag=0;
    if(chkcntr>1)
    for(i=0;i<frm.ch.length;i++)
         if(frm.ch.checked)
    flag=1;
    break;
    else
    if(frm.ch.checked)
    flag=1;
    if(flag==1)
    //checkbox selected,can give any action
    else
    // checkbox not selected,give alert

  • Using Javascript to disable a check box

    Friends,
    I am stuck on what should be a simple requirement and I am hoping you can help.
    I need to disable a form region checkbox if a field on the same form region has anything entered.
    What I have done so far is:
    1) On the item that determines whether the check box should be disabled I have added a call to my Javascript function "onChange="disableDefaultDisplay();" in the "HTML Form Element Attributes"
    2) My javascript funcion is: (this is the basic version, all I am trying to do is disable the check box at this point)
    function disableDefaultDisplay()
    alert("Start of the function");
    var defaultDisplay = document.getElementById("P13_DEFAULT_DISPLAY");
    *defaultDisplay.enabled = false;*
    alert("End of the function");
    Using a combination of firebug and the alert messages I can see that function is called at the correct time (i.e. when the user changes and then leaves the field) and that the values of the variable, defaultDate are set but my attempts to disable the checkbox have yet to work!
    When I look at the type of the checkbox (through the source of the page or firebug) I see the checkbox has the following "fieldset#P13_DEFAULT_DISPLAY.checkbox_group" Do I need to do anything different to disable this type of object?
    Any help would be very much appreciated!

    Hi Andy,
    I was returning to this thread to update it with how I resolved it, so thanks for the detailed response.
    In a nutshell, the solution I used was a loop through the field set(of which there is only one item in it) and disabling it.
    Where you say:
    Secondly, checkboxes are, as you have seen, wrapped within a fieldset tag. The fieldset tag has an ID of the page item name. Each checkbox within that tag has its own ID value, which will be the fieldset ID plus "_n" (where n is a sequential number starting from 0) - thus, the first checkbox will be, for example, "P1_CHECKBOX_0", the second will be "P1_CHECKBOX_1" and so on.From my searching for a solution I had expected to see something like that. But the source for the item I was trying to disable is shown below and I can't see any numbers after it.
    Do you know why? Is it because it is the only item?
    &lt;fieldset id="P13_DEFAULT_DISPLAY" class="checkbox_group"&gt;
    &lt;input type="checkbox" name="p_v18" value="Y" id="P13_DEFAULT_DISPLAY" /&gt;&lt;/fieldset&gt;
    Regards
    Ian
    Edited by: IanC2 on Feb 8, 2009 8:07 PM
    Edited by: IanC2 on Feb 8, 2009 8:08 PM

  • Newb deserving assistance with Adobe Javascript (check boxes and combo boxes)

    Hi, I'm a newb when it comes to javascript (using adobe acrobat pro 6.0).
    I am working on a form that will allow me to autofill checkboxes based off of information chosen. Ideally, I would like to have a selection from a combo box autofill/auto checkmark check boxes. Alternatively, I would be willing to just have different selections presented with check boxes that when filled, would auto checkmark other check boxes (I know how to do this one, but I am not sure how to clear the check boxes if the initial one is unchecked).
    I have the action button tied to the mouse up function. This just errors out.
    var Citrix = this.getField("Citrix")
    var Appro = this.getField("Appro")
    var SAS = this.getField("SAS")
    if (event.target.value=="Yes") {
    Citrix.checkThisBox = true
    Appro.checkThisBox = true
    SAS.checkThisBox = true
    else {
    Citrix.checkThisBox = false
    Appro.checkThisBox = false
    SAS.checkThisBox = false
    I have this that works, but I don't know how to clear the buttons when "Associate" is unchecked.
    if(this.getField("Associate").isBoxChecked(0));
    this.getField("Citrix").checkThisBox(0, true);
    this.getField("Appro").checkThisBox(0, true);
    this.getField("SAS").checkThisBox(0, true);
    The other way I was working on it, was to use a combo box to autofill/checkmark check boxes. But this code doesn't work either.
    function calculateTextField()
    // get the value of the combo box
    var comboValue = this.getField("Select").value;
    // get the state of the checkbox
    var isChecked = (this.getField("Citrix").value == "Yes");
    var textFieldValue = "";
    console.println(comboValue);
    if (isChecked)
    if (comboValue == 0)
    textFieldValue = "";
    if (comboValue == "Associate")
    (this.getField("Citrix").value == "Yes");
    else if (comboValue == "Specialist")
    (this.getField("Citrix").value == "Yes");
    else if (comboValue == "Team Leader")
    (this.getField("Citrix").value == "No");
    else
    (this.getField("Citrix").value == "No");
    else
    textFieldValue = "";
    this.getField("Select").value = textFieldValue;
    Can anyone please assist me with this?
    Thanks,
    Chris

    Hi Gene,
    Thank you for the response. Are you saying that my initial formula should look more like this; ?
    var Citrix = this.getField("Citrix")
    var Appro = this.getField("Appro")
    var SAS = this.getField("SAS")
    if (event.target.value=="Yes") {
    Citrix.checkThisBox = true
    Appro.checkThisBox = true
    SAS.checkThisBox = true
    else {
    if (event.target.value=="Off")
    Citrix.checkThisBox = true
    Appro.checkThisBox = true
    SAS.checkThisBox = true
    Thanks,
    Chris

  • Validating Yes/No Check boxes in Livecycle designer ES2

    Hi everyone,
    I need to validate 5 questions that have yes and no check boxes for "insured" "Spouse" and "Dependents" in one section of my form in LCD ES2 .  I am looking for a javascript code that can check if for each ("insured" "Spouse" and "Dependents")  5 questions has at least a yes or no checked under each and if not an error message is produced.  Thanks for any help you can provided.
    Thanks
    Jagan

    Does anyone have any tips on how to resolve this?  My LiveCycle form is a dynamic form.  It seems like livecycle Designer ES2 has corrupted it or designer ES2 has a bug that makes reader and acrobat print engine not recognize the pages.
    Any help would be great.
    Thanks,
    Josh

  • Check Boxes and Javascripts

    I have a form where there is a table, and inside the table is a row for a Check box for “Sub to Sub”, a row for Work performed by Sub-Contractor Description, a row for Original $$ Amount, and a row for Final $$ Amount Paid.  The Original Amount and Final Amount Paid totals up at the bottom of the page. 
    The user would like to have it set that if the Sub-Contractor selects a check box under “Sub to Sub” row, the dollar amount that is entered for the Original Amount and Final Amount Paid for that row does not add into the Total amounts at the bottom of the page. 
    Is it possible to write a Javascript for this and if so, what would it be?

    Okay.  I put it in the first calculated script which is the total for Original Amount (OA1).  The checkboxes are named Checkbox1.1, Checkbox1.2, etc. But it's not calculating at all.  Any suggestions?
    (function () {
        var f1 = this.getField("OA1");                            
        var a1 = f1.getArray();
        // Get the "Sub to Sub" check boxes
        var a2 = getField("CheckBox1").getArray();
        var sum = 0;
        for (i = 0; i < a1.length; i++) {
            // Only add the value if the check box is not selected
            if (a2[i].value === "Off") {
                sum += +a1[i].value;
        if (sum != 0) {
            event.value = sum;
        } else {
            event.value = ""
    Thanks
    Connie

  • Validation of check boxes...help needed

    Hi
    I have a form in which i need to do a validation between several check boxes there are two categories fo check boxes i want a validation so that one category of the check boxes are checked at a instance
    I am using the following code ..but i think the code is all wrong
    DECLARE
    l_concat VARCHAR2(6);
    l_concat_1 VARCHAR2(6);
    BEGIN
    SELECT BULLAE_FLG||CHERRY_RED_FLG||CYANOTIC_FLG||FLUSHED_FLG||GREY_FLG||JAUNDICED_FLG ||MOTTLED_FLG ||PALE_FLG ||PINK_FLG ||PURPLE_FLG into l_concat FROM SKCOLOR;
    select normal_flg into l_concat_1 from skcolor ;
    IF l_concat IS NULL THEN
    IF l_contact_1 IS NULL THEN
    return false;
    ELSE
    RETURN TRUE;
    END IF;
    ELSE IF l_concat IS NOT NULL THEN
    IF l_contact_1 IS NOT NULL THEN
         return false;
    ELSE
         RETURN TRUE;
         END IF;
    ELSE
    RETURN TRUE;
    END IF;
    END;
    any suggestions ....thanks in advance

    HI,
    Can you eloborate your problem still more clearly.
    Morever i think you need to increase the size of the l_concat, you are concatenating more than 10 flags into a variable of just 6 which will throw an exception,

  • Check box w/validation form troubles

    hello there, I am under a major, major Deadline!
    I have a flash and php contact form with a validation made
    with all input text boxes. I need to add 1 check box to the form,
    but I don't know how to pass it to through.
    here is the code I have for my form now.
    function checkForm():Boolean {
    // this checks whether required fields have been filled in
    // initialize missing flag on assumption everything OK
    var missing:Boolean = false;
    // clear all error text fields
    error1_txt.text = error2_txt.text=error3_txt.text="";
    // check each field
    // if problem is encountered, display message
    // and set missing flag to true
    if (text_field_1.text == "") {
    error1_txt.text = "Please enter your name";
    missing = true;
    if (text_field_2.text.indexOf("@") == -1) {
    error2_txt.text = "Please enter a valid email address";
    missing = true;
    if (text_field_5.text == "") {
    error3_txt.text = "You have not entered any comments";
    missing = true;
    // if missing is true, return false
    // otherwise return true
    return missing ? false : true;
    function sendMessage():Void {
    // check whether form has been correctly filled in
    var formOK:Boolean = checkForm();
    // if no problems, process the form and send variables to
    PHP script
    if (formOK) {
    // Form processing goes here
    message.from = text_field_1.text;
    message.email = text_field_2.text;
    message.comments = text_field_5.text;
    message.sendAndLoad("feedback.php?ck="+ new
    Date().getTime(), messageSent);
    // display message informing user that email is being sent
    gotoAndStop("sending");
    function backToForm():Void {
    // send playhead back to the main form
    gotoAndStop("theForm");
    // create and apply text format for date
    var dateDisplay:TextFormat = new TextFormat();
    dateDisplay.font = "Georgia,Times,_serif";
    theDate_txt.setNewTextFormat(dateDisplay);
    theDate_txt.autoSize = "left";
    // create LoadVars instance to retrieve date from PHP script
    var getDate:LoadVars = new LoadVars();
    // initialize LoadVars to send form data
    // and receive response from the PHP script
    var message:LoadVars = new LoadVars();
    var messageSent:LoadVars = new LoadVars();
    // load date from PHP
    getDate.load("
    http://localhost/phpflash/ch02/today2.php");
    // assign theDate property of the LoadVars instance to text
    field
    getDate.onLoad = function() {
    theDate_txt.text = this.theDate;
    messageSent.onLoad = function() {
    if (this.sent == "OK") {
    gotoAndStop("acknowledge");
    } else {
    gotoAndStop("failure");
    failure_txt.text = this.reason;
    gotoAndStop("theForm");
    any help would be greatly appreciated.
    thanks,
    hutch

    if by check box you mean a radio button, you can add the
    following to your code:

  • Check box or radio button to control image opacity and text field. javascript

    This is a little over head and skill set so I am reaching out to you fine people.
    I am using Adobe acrobat pro x
    I have radio buttons now but I can switch to check box if needed.
    What I need the Java script to do is...
    If Yes is checked then a text field labeled comments appears and an image labeled box changes the opacity to 100%.
    If No is checked then it does the opposite. Text field disappears and image goes to 0% opacity.

    This is the Adobe Reader forum.  You are more likely to receive a helpful answer if you ask in the appropriate Acrobat forum (e.g. Acrobat SDK).

Maybe you are looking for

  • IPod Nano shows on desktop, but not in iTunes

    I haven't used this iPod Nano with my G5 since it was new. Today I connected it, and it shows up on the desktop, but it doesn't appear in iTunes. I unmounted it and connected it again. each time I do that, it tells me it's detected a software update,

  • UPK 3.1.5 player output - HTML file extention

    Hello, Does anyone know if it is possible to modifiy the HTML output in the Player deployment format? More specifically to change the filename suffix from HTML to HTM? Thanks, James

  • Im have trouble

    i am having trouble with Adobe reader it says i don't have it and i do have so what im i suppose to do now

  • Error from the jpa annotation

    when I wrote some sample code according to the mastering EJB 4th Ed and deployed my project in jboss I got lots of exception. I should move annotation location (Ex move the annotation from the getter method to the property declaartion). Is there any

  • Looping Help

    I think I am completely off on the logic here I have everything displaying like I want but when the last window appears and you press "Y" I want the PaymentCalculation method to run again. import javax.swing.JOptionPane; public class MortCalcSwing