表格提交 前台校验单元格不能为空且为数字

sample_editable_1表格提交 前台校验单元格不能为空且为数字

点击提交是触发:


<table class="table table-striped table-hover table-bordered " id="sample_editable_1">
                                        <thead>
                                            <tr>
                                            <th style="text-align:center" width="20%">商品名</th>
                                            <th style="text-align:center" width="25%">商品备注</th>
                                            <th style="text-align:center" width="20%">数量</th>
                                            <th style="text-align:center" width="20%">单位</th>
                                            <th style="text-align:center" width="15%">操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <#list purchaseApplyGoodsDetail as goods>
                                            <tr class="">
                                            <td class="center" style="text-align:center" width="20%">${goods.goodsName}</td>
                                            <td class="center" style="text-align:center" width="25%">${goods.remarks}</td>
                                            <td class="center" style="text-align:center" width="20%">${goods.quantity}</td>
                                            <td class="center" style="text-align:center" width="20%">
                                                <select>
                                                <option value="" selected="true"></option>
                                                <option <#if '${goods.quantifier}'=='1'> selected="true" </#if> value="1">个</option>
                                                <option <#if '${goods.quantifier}'=='2'> selected="true" </#if> value="2">块</option>
                                                <option <#if '${goods.quantifier}'=='3'> selected="true" </#if> value="3">台</option>
                                                <option <#if '${goods.quantifier}'=='4'> selected="true" </#if> value="4">件</option>
                                                <option <#if '${goods.quantifier}'=='5'> selected="true" </#if> value="5">本</option>
                                                </select>
                                            </td>
                                            <td class="center" style="text-align:center" width="15%">
                                                <a class="edit" href="javascript:;">Edit</a>
                                                <a class="delete" href="javascript:;">Delete</a>
                                            </td>
                                            </tr>
                                        </#list>
                                        </tbody>
                                    </table>


function check() {

            var checkResult = true;
            $("#sample_editable_1 tr").each(function(){
                var myTds = $(this).children("td").eq(0).find("input");
                if (myTds.length > 0) {
                    if (myTds[0].value == "") {
                        alert("请输入商品名");
                        checkResult = false;
                        return checkResult;
                    }
                    if (myTds[0].value.length < 1 || myTds[0].value.length > 20) {
                        alert("商品名长度在1~20之间");
                        checkResult = false;
                        return checkResult;
                    }
                }
                myTds = $(this).children("td").eq(2).find("input");
                if (myTds.length > 0) {
                    if (myTds[0].value == "") {
                        alert("请输入数量");
                        checkResult = false;
                        return checkResult;
                    }
                    if (!reg.test(myTds[0].value)) {
                        alert("数量必须是数字");
                        checkResult = false;
                        return checkResult;
                    }
                }
            });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值