Validating Checkbox


Web tier: servlets, JSP, Web frameworks: Validating Checkbox

  1. Validating Checkbox (2 messages)


    I am creating a table in JSP which contains records which are dynamically displayed and which also contains Checkbox.

    I am updating the database depending upon the selection of the checkboxes.

    The functionality is working fine but I am unable to throw a validation message in case the user does not select any of the checkboxes.

    I have used Javascript for that but thats not working.

    Here is the piece of javascript
    <Script language="javascript">
    function validatefunc()
    alert("please select checkbox");


    <form name=myForm action=Acc.jsp>

    <input type =checkbox name=check>
    <input type =submit name=submit onSubmit= onSubmit="javascript:validatefunc();return false;">

    Threaded Messages (2)

  2. Validating Checkbox[ Go to top ]

    try this



    <input type =checkbox name=check id=val>

    now if u have multiple checkboxes u need to generate ids as
    val1, val2, val3 ....

    so also u have to write a loop around the if(to check for val1,val2,val3...). then if condition is not satisfied keep a flag. and check the flag after the loop and display the error.

    hope this helps.

  3. Validating Checkbox[ Go to top ]


    I think ur code is right, but u have used single = (ASSIGNMENT) instead of == (EQUALITY) that might be the problrm..