//输入的必须是数字
$(".xzjl").on("keyup", ".num", function () {
var v = $(this).val();
if (v == 0 || v.length == 0) {
v = 0;
}
else {
v = v.replace(/[^\d]/g, ‘‘);
}
$(this).val(v);
});
function check() {
//判断金钱
var amount = $.trim($("#txtAmount").val());
var regex = /^(([+]?\d*$)|(^[+]?\d+(\.\d+)?$))/;
if (amount != "") {
if (!regex.test(amount)) {
$("#txtAmount").val("0.00");
}
}
}
eg:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
$(function () {
//输入的是数字
$(".xzjl").on("keyup", ".num", function () {
var v = $(this).val();
if (v == 0 || v.length == 0) {
v = 0;
}
else {
v = v.replace(/[^\d]/g, ‘‘);
}
$(this).val(v);
});
});
function check() {
var f = true;
$("#tab_2 tr textarea").each(function () {
var txt = $(this).val();
if (txt.length == 0) {
f = false;
}
});
return f;
}
function sub() {
var f = check();
if (f) {
var data = getTxt();
var para = { t: 6, data: data };
var ajaxUrl = "/Handler/cbk/RequstHelper.ashx";
$.ajax({
url: ajaxUrl,
type: "Post",
dataType: "json",
async: false,
data: para,
success: function (data) {
var r = eval(data);
if (r == "1") {
art.dialog.alert("添加成功");
}
if (r == "2") {
art.dialog.alert("本周已经提交过");
}
else {
art.dialog.alert("系统出现异常!");
}
}
})
}
else {
art.dialog.alert("请填完整所有内容");
}
}
function getTxt() {
var list = "";
$("#tab_2 tr").each(function () {
//var len = $("#tab_2 tr").length;
var subject = $(this).find(".sp").text();
var num = $(this).find(".num").val();
var levelSatisfy = $(this).find(‘option:selected‘).val();
var PersonQue = $(this).find(‘.txt1‘).val();
var JishuQue = $(this).find(‘.txt2‘).val();
var CompanyQue = $(this).find(‘.txt3‘).val();
var WeekPlan = $(this).find(‘.txt4‘).val();
list += subject + "," + num + "," + levelSatisfy + "," + PersonQue + "," + JishuQue + "," + CompanyQue + "," + WeekPlan + "|";
});
return list;
}
</script>
<style type="text/css">
.auto-style1 {
height: 37px;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPH" runat="server">
<div class="xzjl" id="xzjl">
<div class="tb_main">
<div id="tablecontent" style="padding-top: 0;">
<div class="ui_toptable j_outerheight">
<table cellpadding="0" cellspacing="0" class="headtable wb100" id="tab_1">
<thead>
<tr>
<th colspan="3" class="boBo">基础信息</th>
<th colspan="3" class="boBo">解决方案</th>
<th rowspan="2" width="28%" class="boBo">本周计划</th>
</tr>
<tr>
<th width="10%">科目</th>
<th width="8%">具体数量</th>
<th width="12%">是否满意</th>
<th width="14%">人员问题</th>
<th width="14%">技术问题</th>
<th width="14%">公司问题</th>
</tr>
</thead>
</table>
</div>
<!-- -->
<div class="tableshow" style="overflow: auto;" id="j_scrollbox">
<table cellpadding="0" cellspacing="0" class="wb100 alingcenter ui_bottomtab" id="tab_2">
<tbody class="num">
<tr class="target_tr" height="60">
<td width="10%"><span class="sp">在施数量</span></td>
<td width="8%">
<input type="text" class=" num" name="ActivityPeopleNum" style="width: 90px;" />
</td>
<td width="12%">
<select class="xzjl_BDYS90">
<option value="非常满意">非常满意</option>
<option value="满意">满意</option>
<option value="一般">一般</option>
<option value="不满意">不满意</option>
<option value="不是很满意">不是很满意</option>
<option value="非常不满意">非常不满意</option>
</select>
</td>
<td width="14%">
<textarea class="Tab1 txt1"></textarea></td>
<td width="14%">
<textarea class="Tab1 txt2"></textarea></td>
<td width="14%">
<textarea class="Tab1 txt3"></textarea></td>
<td width="28%">
<textarea class="Tab1 txt4"></textarea></td>
</tr>
<tr class="target_tr" height="60">
<td width="10%"><span class="sp">问题工地</span></td>
<td width="8%">
<input type="text" class=" num" name="" style="width: 90px;" />
</td>
<td width="12%">
<select class="xzjl_BDYS90">
<option value="非常满意">非常满意</option>
<option value="满意">满意</option>
<option value="一般">一般</option>
<option value="不满意">不满意</option>
<option value="不是很满意">不是很满意</option>
<option value="非常不满意">非常不满意</option>
</select>
</td>
<td width="14%">
<textarea class="Tab1 txt1"></textarea></td>
<td width="14%">
<textarea class="Tab1 txt2"></textarea></td>
<td width="14%">
<textarea class="Tab1 txt3"></textarea></td>
<td width="28%">
<textarea class="Tab1 txt4"></textarea></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="footer pad_top12 j_outerheight">
<span class="YS_1">
<input type="button" value="提交" id="btnSubmit" class="anYS2_2 mar_lef10 bone" onclick="sub()" /></span><br class="clear" />
</div>
</div>
</asp:Content>