index.php为入口,为一个表单,结构比较简单。只粘贴js代码部分:
| function onext(){ var isMobile=/^(?:13d|15d|18d)d{5}(d{3}|*{3})$/; var isPhone=/^((0d{2,3})-)?(d{7,8})(-(d{3,}))?$/; var iname=$('input[name=iname]').val(); var phone=$('input[name=phone]').val(); var wp=$('input[name=workplace]').val(); if(iname=='' || phone=='' || wp==''){ showDialog('alert', '请检查姓名、电话号码或者工作单位有没有填写', "在线登记", "430"); return false; } if(phone!='' && !isMobile.test(phone) && !isPhone.test(phone)){ showDialog('alert', '你填写的电话号码格式不正确。', "在线登记", "430"); return false; } document.ad.submit();} |
引用了一个jquery.showdialog的函数
| function detectMacXFF() { var userAgent = navigator.userAgent.toLowerCase(); if(userAgent.indexOf("mac") != -1 && userAgent.indexOf("firefox") != -1) { return true; }}function in_array(needle, haystack) { if(typeof needle == "string" || typeof needle == "number") { for(var i in haystack) { if(haystack[i] == needle) { return true; } } } return false;}function sd_load(sd_width) { if(sd_width) { $("#SD_window").css("width", sd_width + "px"); } var sd_top = ($(window).height() - $("#SD_window").height()) / 2 + $(document).scrollTop(); if(sd_top < 0) { sd_top = 0; } var sd_left = ($(window).width() - $("#SD_window").width()) / 2; if(sd_left < 0) { sd_left = 0; } $("#SD_window").css("top", sd_top); $("#SD_window").css("left", sd_left);}function sd_remove() { $("#SD_close,#SD_cancel,#SD_/confirm/i").unbind("click"); $("#SD_window,#SD_overlay,#SD_HideSelect").remove(); if(typeof document.body.style.maxHeight == "undefined") { $("body","html").css({height: "auto", width: "auto"}); }}function showDialog(mode, msg, t, sd_width) { var sd_width = sd_width ? sd_width : 400; var mode = in_array(mode, ['/confirm/i', 'window', 'info', 'loading']) ? mode : 'alert'; var t = t ? t : "提示信息"; var msg = msg ? msg : ""; var confirmtxt = confirmtxt ? confirmtxt : "确定"; var canceltxt = canceltxt ? canceltxt : "取消"; sd_remove(); try { if(typeof document.body.style.maxHeight === "undefined") { $("body","html").css({height: "100%", width: "100%"}); if(document.getElementById("SD_HideSelect") === null) { $("body").append(""); } } else { if(document.getElementById("SD_overlay") === null) { $("body").append(""); } } if(mode == "alert") { if(detectMacXFF()) { $( |