Validform 基于表单验证

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../taglib/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${ctx}" />
<meta http-equiv="X-UA-Compatible" content="IE=8,IE=9" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
    var ctx = '${ctx}';
</script>
<title>档案管理新增</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" href="js/common/jquery-ui-1.10.3/themes/base/jquery.ui.all.css" />
<link rel="stylesheet" type="text/css" href="js/common/jPaginate/css/style.css" />
<script src="js/common/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="js/common/jquery-ui-1.10.3/ui/jquery-ui.js"></script>
<script src="js/common/jquery.cookie.js" type="text/javascript"></script>
<script src="js/common/html5.js" type="text/javascript"></script>
<script src="js/common/Validform_v5.3.2_min.js" type="text/javascript"></script>
<script src="js/common/datepicker/WdatePicker.js" type="text/javascript"></script>
<script src="js/common/jPaginate/jquery.paginate.js" type="text/javascript"></script>
<style type="text/css">
.validnum{
    border-color: red;
}
</style>
<script>
    $(function() {
        $("#tabs").tabs();

    
        $(".infoForm").Validform({
               tiptype: function(msg, o, cssctl) {
                    if (!o.obj.is("form")) {
                        var objtip = o.obj.siblings(".Validform_checktip");
                        cssctl(objtip, o.type);
                        objtip.text(msg);
                    } else {
                        var objtip = o.obj.find("#msgdemo");
                       cssctl(objtip, o.type);
                        objtip.text(msg);
                   }
               },
                showAllError : true,
                ajaxPost : true,
                callback : function(data) {
                    if(data.status=="y"){
                        alert(data.message);
                        location.href = "ShipInfo/shipInfoListAction.do";
                    }else{
                        alert(data.message);
                    }
                }
         });

    });
</script>
</head>
<body>
    <div class="mainright minheight">
        <div class="content">
            <p class="title">
                首页 » <span>档案管理新增</span>
            </p>
            <span class="line"></span>
            <div class="shipdetails">
                <form class="infoForm"  action="ShipInfo/add_j.do">
                    <button type="submit">发布</button>
                    <button type="button" onclick="history.go(-1)">返回</button>
                    <div id="tabs">
                        <ul>
                            <li><a href="ShipInfo/ShipInfo_add.jsp#tabs-1">船舶资料</a></li>
                            <li><a href="ShipInfo/ShipInfo_add.jsp#tabs-2">船体部分</a></li>
                            <li><a href="ShipInfo/ShipInfo_add.jsp#tabs-3">吨位</a></li>
                            <li><a href="ShipInfo/ShipInfo_add.jsp#tabs-4">主机</a></li>
                            <li><a href="ShipInfo/ShipInfo_add.jsp#tabs-5">船舶所有人</a></li>
                            <li><a href="ShipInfo/ShipInfo_add.jsp#tabs-6">船舶管理公司</a></li>
                            <li><a href="ShipInfo/ShipInfo_add.jsp#tabs-7">船舶经营人</a></li>
                        </ul>
                        <div id="tabs-1">
                            <dl>
                                <dt><label>船名:</label></dt>
                                <dd><s:textfield name="shipInfo.vesselName" datatype="*"/><font style="color:red;">*</font><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>原船名:</label></dt>
                                <dd><s:textfield name="shipInfo.origVesselName" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>MMSI:</label></dt>
                                <dd><s:textfield name="shipInfo.mmsi" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>IMO:</label></dt>
                                <dd><s:textfield name="shipInfo.imo" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>呼号:</label></dt>
                                <dd><s:textfield name="shipInfo.callSign"/><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>船舶类型:</label></dt>
                                <dd><s:textfield name="shipInfo.subType" datatype="*"/><font style="color:red;">*</font><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>船速:</label></dt>
                                <dd><s:textfield name="shipInfo.speed" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>船级社:</label></dt>
                                <dd><s:textfield name="shipInfo.classedBy" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>船籍港:</label></dt>
                                <dd><s:textfield name="shipInfo.portOfRegistry" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>船籍:</label></dt>
                                <dd><s:textfield name="shipInfo.origOwner" datatype="*"/><font style="color:red;">*</font><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>原船籍:</label></dt>
                                <dd><s:textfield name="shipInfo.origCDOwner" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>造船厂:</label></dt>
                                <dd><s:textfield name="shipInfo.builder" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>造船地点:</label></dt>
                                <dd><s:textfield name="shipInfo.shipyardCountry" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>造船日期:</label></dt>
                                <dd><s:textfield name="shipInfo.contractDate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00'})" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>安放龙骨日期:</label></dt>
                                <dd><s:textfield name="shipInfo.keelLaid" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00'})" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <dl>
                                <dt><label>下水日期:</label></dt>
                                <dd><s:textfield name="shipInfo.launched" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00'})" /><em class="Validform_checktip"></em></dd>
                            </dl>
                            <div class="clear"></div>
                        </div>
                        <div id="tabs-2">
                            <ul>
                                <dl>
                                    <dt><label>船舱数:</label></dt>
                                    <dd><s:textfield name="shipInfo.cabins" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>甲板数:</label></dt>
                                    <dd><s:textfield name="shipInfo.decks" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>总长:</label></dt>
                                    <dd><s:textfield name="shipInfo.loa" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>型深:</label></dt>
                                    <dd><s:textfield name="shipInfo.depth"  datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>型宽:</label></dt>
                                    <dd><s:textfield name="shipInfo.beam"  datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>吃水:</label></dt>
                                    <dd><s:textfield name="shipInfo.draft" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>排水量:</label></dt>
                                    <dd><s:textfield name="shipInfo.displacementTonnage" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>冷藏总容量:</label></dt>
                                    <dd><s:textfield name="shipInfo.reeferCapacity" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>冷藏集装箱:</label></dt>
                                    <dd><s:textfield name="shipInfo.reeferTEU" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>翼液货舱:</label></dt>
                                    <dd><s:textfield name="shipInfo.tanksWing" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>液货舱:</label></dt>
                                    <dd><s:textfield name="shipInfo.permanentBallastCapacity" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>中心液货舱:</label></dt>
                                    <dd><s:textfield name="shipInfo.tanksCentre" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>甲板液货舱:</label></dt>
                                    <dd><s:textfield name="shipInfo." /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>污水舱:</label></dt>
                                    <dd><s:textfield name="shipInfo.tanksSlop" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>是否配置原油洗舱:</label></dt>
                                    <dd><s:textfield name="shipInfo.crudeOilWashing" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>是否装有惰性气体:</label></dt>
                                    <dd><s:textfield name="shipInfo.inertGasSystem" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                            </ul>
                            <div class="clear"></div>
                        </div>
                        <div id="tabs-3">
                            <ul>
                                <dl>
                                    <dt><label>总吨位:</label></dt>
                                    <dd><s:textfield name="shipInfo.grossTonnage" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>载重吨:</label></dt>
                                    <dd><s:textfield name="shipInfo.dwt" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>净吨:</label></dt>
                                    <dd><s:textfield name="shipInfo.cgt" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                            </ul>
                            <div class="clear"></div>
                        </div>
                        <div id="tabs-4">
                            <ul>
                                <dl>
                                    <dt><label>主机制造商:</label></dt>
                                    <dd><s:textfield name="shipInfo.engineBuilder" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>主机种类:</label></dt>
                                    <dd><s:textfield name="shipInfo.engineMake" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>主机型号:</label></dt>
                                    <dd><s:textfield name="shipInfo.engineModel" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>主机速率:</label></dt>
                                    <dd><s:textfield name="shipInfo.engineRPM"  datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>主机性能:</label></dt>
                                    <dd><s:textfield name="shipInfo.engineSpeed" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>主机燃料:</label></dt>
                                    <dd><s:textfield name="shipInfo.engineType" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>主机总功率:</label></dt>
                                    <dd><s:textfield name="shipInfo.engineHPTotal" datatype="n"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                            </ul>
                            <div class="clear"></div>
                        </div>
                        <div id="tabs-5">
                            <ul>
                                <dl>
                                    <dt><label>公司:</label></dt>
                                    <dd><s:textfield name="addressandrep.companyName" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>邮编:</label></dt>
                                    <dd><s:textfield name="addressandrep.postalCode" datatype="p"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>电话:</label></dt>
                                    <dd><s:textfield name="addressandrep.telephone" datatype="ph" ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>传真:</label></dt>
                                    <dd><s:textfield name="addressandrep.facsimile" datatype="f" ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>邮箱:</label></dt>
                                    <dd><s:textfield name="addressandrep.emailNetwork" datatype="e"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>网址:</label></dt>
                                    <dd><s:textfield name="addressandrep.line1LabelAddress" datatype="url"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人:</label></dt>
                                    <dd><s:textfield name="shipInfo.owner" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人船籍:</label></dt>
                                    <dd><s:textfield name="addressandrep." /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人电话:</label></dt>
                                    <dd><s:textfield name="addressandrep." datatype="m"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人邮箱:</label></dt>
                                    <dd><s:textfield name="addressandrep." datatype="e"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人邮编:</label></dt>
                                    <dd><s:textfield name="addressandrep." datatype="p"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                            </ul>
                            <div class="clear"></div>
                        </div>
                        <div id="tabs-6">
                            <ul>
                                <dl>
                                    <dt><label>公司:</label></dt>
                                    <dd><s:textfield name="addressandrep1.companyName" datatype="*"/><font style="color:red;">*</font><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>邮编:</label></dt>
                                    <dd><s:textfield name="addressandrep1.postalCode" datatype="p"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>电话:</label></dt>
                                    <dd><s:textfield name="addressandrep1.telephone" datatype="ph" ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>传真:</label></dt>
                                    <dd><s:textfield name="addressandrep1.facsimile" datatype="f" ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>邮箱:</label></dt>
                                    <dd><s:textfield name="addressandrep1.emailNetwork" datatype="e"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>网址:</label></dt>
                                    <dd><s:textfield name="addressandrep1.line1LabelAddress" datatype="url"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人:</label></dt>
                                    <dd><s:textfield name="shipInfo.manager" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人电话:</label></dt>
                                    <dd><s:textfield name="addressandrep1." datatype="m"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人邮箱:</label></dt>
                                    <dd><s:textfield name="addressandrep1." datatype="e"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                            </ul>
                            <div class="clear"></div>
                        </div>
                        <div id="tabs-7">
                            <ul>
                                <dl>
                                    <dt><label>公司:</label></dt>
                                    <dd><s:textfield name="addressandrep2.companyName" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>邮编:</label></dt>
                                    <dd><s:textfield name="addressandrep2.postalCode" datatype="p"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>电话:</label></dt>
                                    <dd><s:textfield name="addressandrep2.telephone" datatype="ph" ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>传真:</label></dt>
                                    <dd><s:textfield name="addressandrep2.facsimile" datatype="f" ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>邮箱:</label></dt>
                                    <dd><s:textfield name="addressandrep2.emailNetwork" datatype="e"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>网址:</label></dt>
                                    <dd><s:textfield name="addressandrep2.line1LabelAddress" datatype="url"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人:</label></dt>
                                    <dd><s:textfield name="shipInfo.operator" /><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人电话:</label></dt>
                                    <dd><s:textfield name="addressandrep2." datatype="m"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                                <dl>
                                    <dt><label>联系人邮箱:</label></dt>
                                    <dd><s:textfield name="addressandrep2." datatype="e"  ignore="ignore"/><em class="Validform_checktip"></em></dd>
                                </dl>
                            </ul>
                            <div class="clear"></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
原文地址:https://www.cnblogs.com/lbangel/p/3394340.html