日期:2014-05-17 浏览次数:20531 次
$(function() { $("#form2").validate( { /*自定义验证规则*/ rules: { userpassword: { required: true, minlength: 6 }, useremail: { required: true, email: true }, usernamebox: { required: true, minlength: 2 } }, /*错误提示位置*/ errorPlacement: function(error, element) { error.appendTo(element.siblings("span")); }, //自定义提示信息 messages: { userpassword: { required: "请输入密码" }, useremail: { required: "请输入Email地址", email: "请输入正确的email地址" }, usernamebox: { required: "请输入姓名" } } } ); })
function testMessageBox(ev) { var objPos = mousePosition(ev); messContent = "<form id='form2' runat='server'><div style='text-align:left;' runat='server' id='div2'><div><input id='useremail' class='box' type='text' onclick='texteffect();' runat='server'/><br/><span style='color:Red;font-size:12px'></span></div><div><input id='userpassword' type='password' class='box' onclick='texteffect();' runat='server'/><br /><span style='color:Red;font-size:12px'></span></div><div><input id='usernamebox' type='text' class='box' onclick='texteffect();' runat='server' /><br /><span style='color:Red;font-size:12px'></span></div><input id='Button1' type='button' value='注册' onclick='loginMsg();' runat='server' /><div id='Div3'><img src='../../images/logo.png'/></div></div></form>"; showMessageBox('欢迎加入我们',messContent,objPos,350); }
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <input type="button" id="testDialog" name="testDialog" onclick="javascript:$('#dialog').dialog('open');" value="测试Dialog" /> <div id="dialog" title="Dialog Title"> //放入表单然后在下面外面继续写的jquery form的验证, <input type="text" name="modifyValue" id="modifyValue" value="" /> </div> <script language="javascript" type="text/javascript"> var InitDialog = function () { $('#dialog').dialog({ autoOpen: false, width: 600, buttons: { "Ok": function() { //触发你的jquery form验证通过进行下一步,关闭dialog $(this).dialog("close"); }, "Cancel&