当前位置: 代码迷 >> Java Web开发 >> js、checkbox
  详细解决方案

js、checkbox

热度:203   发布时间:2016-04-12 22:48:58.0
js、checkbox求助
现有代码
function dsubmitStory(){
????if($("#u_tag").val()?==""?||?$("#u_tag").val()?=="最少要入兩個標籤,用“,”分隔"){
????????alert("標籤不能為空!");
????????return?false;
????}else{
????????var?t?=?$("#u_tag").val().split(",");
????????if(t.length<2){
????????????alert("請最少輸入兩個標籤!");
????????????return?false;
????????}else?if(t.length>=2&&t.length<=3){
????????????for(var?j=0;j<t.length;j++){
????????????????if(t[j].length>20){
????????????????????alert("標籤長度不能超過20!");
????????????????????return?false;
????????????????}
????????????}
????????}else?if(t.length>3){
????????????alert("最多只能輸入三個標籤!");
????????????return?false;
????????}
????????//验证通过执行
????????//document.addStory.submit();?
????}
document.addStory.submit();?
}

以及
<c:forEach var="p" items="${TagList}" varStatus="vs">
                            <td  valign="top">
                            <c:if test="${vs.index!=0}"><div class="form-ul-left"></div></c:if>
                                <div class="form-ul-div">
                                    <ul class="form-ul">
                                        <li><input class="form-ul-li-input" type="checkbox" value="${p.id}" name="ftagid" id="t_${p.id}">${p.tag}</li>
                                    </ul>
                                </div>
                            </td>
                            </c:forEach>

现在我想要在js里面加上对checkbox的验证,条件是至少选择一个复选框,否侧弹出验证不通过的提示,自己弄了一下午了,求助啊
JavaScript HTML checkbox

------解决方案--------------------

  function  validate(){
  相关解决方案