<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script> <script type="text/javascript"> function checkForm(form) { if ($("#receivemobile").val() == "") { alert("收货人手机号码不能为空!"); $("#receivemobile").focus(); return false; } if ($("#receivemobile").val().length != 11) { alert("请输入正确的11位收货人手机号码!"); $("#receivemobile").focus(); return false; } var patrnmobile = /^1[3|4|5|8][0-9]\d{4,8}$/; if (!patrnmobile.exec($("#receivemobile").val())) { alert("请输入正确的收货人手机号码!"); $("#receivemobile").focus(); return false } var patrn = /^[0-9]*[1-9][0-9]*$/; if (!patrn.exec($("#count").val())) { alert("请输入正整数!");//不包括0 $("#count").val("");//清空值 $("#count").focus(); return false; } if ($("#address").val().length < 1 || $("#address").val().length > 20) { alert("地址长度应在1-20之间!"); $("#address").focus(); return false; } if (form.email.value.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)==null) {//可以不是用id取的 alert("请输入正确的邮箱!"); return false; } //document.form.submit();//方法提交 //$("#form").submit();//表单提交 //window.location = "xxx.jsp";//跳转 //window.location.reload();//重载 刷新 } </script> <form action="addOrder" method="post" onsubmit="return checkForm(this)" name="form"> receivemobile:<input type="text" name="receivemobile" id="receivemobile"><br> count:<input type="text" name="count" id="count"><br> email:<input type="text" name="email"><br> address:<input type="text" name="address" id="address"><br> <input type="submit" name="submit"> </form>
系统毫秒数(可做数据表的PK):
String timemillis = String.valueOf(System.currentTimeMillis())
<input type="text" name="orderid" id="orderid" class="text" value="<%=timemillis%>" readonly>
文本框提示输入:
<input type="text" name="xxcount" id="xxcount" value="1~9999" onfocus="javascript:if(this.value==‘1~9999‘)this.value=‘‘;"
onblur="javascript:if(this.value==‘‘||this.value==0)this.value=‘1~9999‘;">
jquery常见function定义:
$(function(){
$("#btnSubmit").click(function(){
$("#form").submit();
});
});
时间: 2024-10-11 07:39:05