Question: I have two checkboxes for gender . male and female. how will i set my validation for at least one gender should be selected. I also have 1 week set of days, from monday to sunday. it is also at least one selection of days. here is my jquery

```
$(document).ready(function(){
            // --- set required message --- //

                var msg="";
                var elements = document.getElementsByTagName("INPUT");

                for (var i = 0; i < elements.length; i++) {
                   elements[i].oninvalid =function(e) {
                        if (!e.target.validity.valid) {
                        switch(e.target.name){                              
                            case 'gender' :
                                e.target.setCustomValidity("Please select at least one gender.");break;                             
                            case 'days' :
                                e.target.setCustomValidity("Please select at least one day.");break;
                            case 'location' :
                                e.target.setCustomValidity("Please enter a location where the image can be seen.");break;
                        default : e.target.setCustomValidity("");break;

                        }
                       }
                    };
                   elements[i].oninput = function(e) {
                        e.target.setCustomValidity(msg);
                    };
                }
            });

<input type=checkbox name=gender[] required>Male
<input type=checkbox name=gender[] required>Female

<input type=checkbox name=days[] required>Monday
<input type=checkbox name=days[] required>Tuesday
<input type=checkbox name=days[] required>Wednesday
<input type=checkbox name=days[] required>Thursday
<input type=checkbox name=days[] required>Friday
<input type=checkbox name=days[] required>Saturday
<input type=checkbox name=days[] required>Sunday

```

Answer: 
By default Struts2 uses `xhtml` theme for generating html content of form fields like `textfield` tag. This theme is using a `<table>` layout with `<tr><td>` for input elements. This breaks your design because these elements is placed outside `<div>` tag. If you want to use `<div>` instead of `<tr><td>` for your input fields then you can choose `css_xhtml` theme. If you want to omit to generate `<tr><td>` or `<div>` then you can use `simple` theme. For example

```jsp
<s:form theme="simple">
 <div style="display: none;" id="tt">
   <s:textfield name="myfield" />
 </div>
</s:form>

```

**References:**

* [Themes and templates](https://struts.apache.org/tag-developers/themes-and-templates)
i tested . working 100% for me :)

```
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>Insert title here</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        //jquery methods go here...

  $("#btnhidediv").change(function(){

        $("#togglediv").toggle();

    });

});
</script>

</head>
<body>
<form>
<div  id="togglediv" style="display: none;">
<s:textfield  type="text" name="xyz" key="xyz" size="11" label="xyz"></s:textfield><br />

<p>Hieeeeeeeeeee</p>

</div>
<input type="text" id="btnhidediv">
</form>
<body>
</html>

```