Forráskód Böngészése

git-svn-id: https://192.168.57.71/svn/jsgkj@1917 931142cf-59ea-a443-aa0e-51397b428577

ld_jiangxf 8 éve
szülő
commit
a3bd977e53

+ 31 - 9
gkjsjy/trunk/WebContent/WEB-INF/pages/gkyxtjyfx/hxhbtj/hxhbtjEdit.jsp

@@ -15,6 +15,28 @@
 			initgkSelect('szgksel','${szgkid }','','showgq','80%');
 			iFrameHeightIframe('${menuid}');//自适应高度
 		});
+		
+		function percent(obj){
+			var reg = /^[+-]?\d*\.?\d{0,1}$/;
+			if(!reg.test(obj.value)){
+				obj.value = obj.value.substring(0,obj.value.length-1);
+				obj.value = obj.value.replace(/[^\d.-]/g,""); //清除"数字"和"."以外的字符
+				obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
+				obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
+				obj.value = obj.value.replace(/\-{2,}/g,"-"); //只保留第一个, 清除多余的
+				obj.value = obj.value.replace("-","$#$").replace(/\-/g,"").replace("$#$","-");
+				obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d).*$/,'$1$2.$3'); //只能输入两个小数
+			}else{
+				obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
+			}
+		}
+		function twoNumeber(obj){
+			obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
+			obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
+			obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
+			obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
+			obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d)(\d).*$/,'$1$2.$3$4'); //只能输入两个小数
+		}
 	</script>
 	<style type="text/css">
 	.apply th {
@@ -62,35 +84,35 @@
 						<tr>
 							<th colspan="2">本月完成量(TEU):&nbsp;</th>
 							<td>
-								<input type="text" class="form-control" id="bywcl" name="bywcl" value="${record.bywcl }" onkeyup="num(this)">
+								<input type="text" class="form-control" id="bywcl" name="bywcl" value="${record.bywcl }" onkeyup="twoNumeber(this)">
 							</td>
 							<th colspan="2">本年累计量(TEU):&nbsp;</th>
 							<td>
-								<input type="text" class="form-control" id="bnljl" name="bnljl" value="${record.bnljl }" onkeyup="num(this)">
+								<input type="text" class="form-control" id="bnljl" name="bnljl" value="${record.bnljl }" onkeyup="twoNumeber(this)">
 							</td>
 							<th colspan="2">同比增长数(%):&nbsp;</th>
 							<td>
-								<input type="text" class="form-control" id="tbzzs" name="tbzzs" value="${record.tbzzs }" onkeyup="num(this)">
+								<input type="text" class="form-control" id="tbzzs" name="tbzzs" value="${record.tbzzs }" onkeyup="percent(this)">
 							</td>
 						</tr>
 						<tr>
 							<th rowspan="2">其中:</th>
 							<th>外贸:&nbsp;</th>
-							<td><input type="text" class="form-control" id="wmjzxttl" name="wmjzxttl" value="${record.wmjzxttl }" onkeyup="num(this)"></td>
+							<td><input type="text" class="form-control" id="wmjzxttl" name="wmjzxttl" value="${record.wmjzxttl }" onkeyup="twoNumeber(this)"></td>
 							<th rowspan="2">其中:</th>
 							<th>外贸:&nbsp;</th>
-							<td><input type="text" class="form-control" id="nwmjzxttl" name="nwmjzxttl" value="${record.nwmjzxttl }" onkeyup="num(this)"></td>
+							<td><input type="text" class="form-control" id="nwmjzxttl" name="nwmjzxttl" value="${record.nwmjzxttl }" onkeyup="twoNumeber(this)"></td>
 							<th rowspan="2">其中:</th>
 							<th>外贸:&nbsp;</th>
-							<td><input type="text" class="form-control" id="wmtbzzs" name="wmtbzzs" value="${record.wmtbzzs }" onkeyup="num(this)"></td>
+							<td><input type="text" class="form-control" id="wmtbzzs" name="wmtbzzs" value="${record.wmtbzzs }" onkeyup="percent(this)"></td>
 						</tr>
 						<tr>
 							<th>内贸:&nbsp;</th>
-							<td><input type="text" class="form-control" id="nmjzxttl" name="nmjzxttl" value="${record.nmjzxttl }" onkeyup="num(this)"></td>
+							<td><input type="text" class="form-control" id="nmjzxttl" name="nmjzxttl" value="${record.nmjzxttl }" onkeyup="twoNumeber(this)"></td>
 							<th>内贸:&nbsp;</th>
-							<td><input type="text" class="form-control" id="nnmjzxttl" name="nnmjzxttl" value="${record.nnmjzxttl }" onkeyup="num(this)"></td>
+							<td><input type="text" class="form-control" id="nnmjzxttl" name="nnmjzxttl" value="${record.nnmjzxttl }" onkeyup="twoNumeber(this)"></td>
 							<th>内贸:&nbsp;</th>
-							<td><input type="text" class="form-control" id="nmtbzzs" name="nmtbzzs" value="${record.nmtbzzs }" onkeyup="num(this)"></td>
+							<td><input type="text" class="form-control" id="nmtbzzs" name="nmtbzzs" value="${record.nmtbzzs }" onkeyup="percent(this)"></td>
 						</tr>
 					</table>
 					<h2 align="center" style="margin-top:0px;"><font style="font-size:16px;color:#196794;font-family:微软雅黑;font-weight: bold;">集装箱航线航班开辟情况</font></h2>