本地测试没有问题,上到服务器(service 2003)ie不行了!
[code="java"]
$(document).ready(function(){
$("#address").blur(function(){
if($("#address").val().trim()==""){
$("#addressInfo").html("x 详细地址不能为空!").css("color","red");
}else{
if($("#address").val().trim().length<5){
$("#addressInfo").html("x 长度不能小于5个字符,请认真填写!").css("color","red");
}else{
$("#addressInfo").html("(具体地址填写)").css("color","blue");
}
}
});
$("#nameLogin").blur(function(){
if($("#nameLogin").val().trim()==""){
$("#loginInfo").html("账号不能为空!").css("color","red");
}else{
$("#loginInfo").html("");
}
});
$("#passWordLogin").blur(function(){
if($("#passWordLogin").val().trim()==""){
$("#loginInfo").html("密码不能为空!").css("color","red");
}else {
$("#loginInfo").html("");
}
});
$("#username").blur(function(){
//获得输入框的数值
var userName =$("#username").val().trim();
// 清空提示框信息
$("#userNameInfo").html("");
if(userName==""){
$("#userNameInfo").html("x 登录名不能为空");
$("#userNameInfo").css("color","red").css("fontSize","10px").show("show",2);
}else{
var pattern = /^[A-Za-z0-9]{4,8}$/;
if (!pattern.test(userName)) {
$("#userNameInfo").html("× 登录名格式不正确");
$("#userNameInfo").css("color", "red").css("fontSize","10px").show("slow",2);
}else{
$("#userNameInfo").html("√ 正确");
$("#userNameInfo").css("color", "blue").css("fontSize","10px").show("slow",2);
}
}});
$("#password").blur(function(){
//获得输入框的数值
var passWord =$("#password").val().trim();
$("#passWordInfo").html("");
if(passWord==""){
$("#passWordInfo").html("x 密码不能为空");
$("#passWordInfo").css("color","red").css("fontSize","10px").show("show",2);
}else{
var pattern = /^[A-Za-z0-9]{6,8}$/;
if(!pattern.test(passWord)){
$("#passWordInfo").html("× 密码格式不正确");
$("#passWordInfo").css("color", "red").css("fontSize","10px").show("slow",2);
}else{
$("#passWordInfo").html("√ 正确");
$("#passWordInfo").css("color", "blue").css("fontSize","10px").show("slow",2);
}
}
});
$("#passWord2").blur(function(){
var passWord2 = $("#passWord2").val().trim();
var passWord =$("#password").val().trim();
$("#passWord2Info").html("");
if(passWord2==""){
$("#passWord2Info").html("x 密码不能为空");
$("#passWord2Info").css("color","red").css("fontSize","10px").show("show",2);
}else {
$("#passWord2Info").html("");
if(passWord!=passWord2){
$("#passWord2Info").html("x 两次输入不一致");
$("#passWord2Info").css("color","red").css("fontSize","10px").show("show",2);
}else{
$("#passWord2Info").html("√ 正确");
$("#passWord2Info").css("color", "blue").css("fontSize","10px").show("slow",2);
}
}
});
$("#province").change(function(){
$("#city").empty();
var id = $(this).find("option:selected").attr("value");
$.ajax({
type: "GET",
url: "/zone/city/"+id,
success: function(data){
$.each(data,function(i, o){
$("#city").append("<option value='"+o.id+"'>"+o.name+"</option>");
});
}
});
});
$("#province").change();
$("#subBtn").click(function(){
if(!checkForm())
return false;
var username = $("#username").val().trim();
var password = $("#password").val().trim();
var province = $("#province").val().trim();
var city = $("#city").val();
var sex = $("#sex").val();
submitForm(username, password, province, city, sex);
});
});
//定义方法--验证是否为空
function isNull(ele) {
var _form = document.searchForm;
if (_form[ele].value == "") {
_form[ele].focus();
return true;
}
return false;
}
function checkForm(){
var _form = document.searchForm;
if (isNull("username")) {
$("#userNameInfo").html("x 登录名不能为空").css("color", "red").css("fontSize","10px").show("slow",2);
_form.name.focus();
return false;
}else if($("#username").val().trim().length<4){
$("#userNameInfo").html("x 登录名长度不能小于4个字符");
_form.name.focus();
return false;
}
if (isNull("password")) {
$("#passWordInfo").html("x 登录密码不能为空").css("color", "red").css("fontSize","10px").show("slow",2);
_form.password.focus();
return false;
}
if (isNull("password2")) {
$("#passWord2Info").html("x 确认密码不能为空!").css("color", "red").css("fontSize","10px").show("slow",2);
_form.password2.focus();
return false;
}
if(_form.password.value!=_form.password2.value){
$("#passWord2Info").html("x 您两次输入的密码不一致,请重新输入!").css("color", "red").css("fontSize","10px").show("slow",2);
alert("");
_form.password2.focus();
return false;
}
if (isNull("checkcode")) {
$("#checkCodeInfo").html("x 验证码不能为空!").css("color", "red").css("fontSize","10px").show("slow",2);
_form.checkcode.focus();
return false;
}
if( !Utils.checkCode($("#checkcode").val()) ){
$("#checkCodeInfo").html("x 验证码错误!").css("color", "red").css("fontSize","10px").show("slow",2);
return false;
}
if ($("#service").attr("checked")!="checked") {
$("#serviceInfo").html("x 请仔细阅读并同意用户服务协议并同意再注册!").css("color", "red").css("fontSize","10px").show("slow",2);
return false;
}else{
$("#serviceInfo").html("√ 正确").css("color", "blue").css("fontSize","10px").show("slow",2);
}
return true;
}
var submitForm = function(username, password, province, city, sex){
$.ajax({
type: "POST",
url: "/reg/create",
data:{"username":username,"password":password,
"province":province,"city":city,
"sex":sex},
success: function(data){
alert(data.message);
if(data.status){
if(window.parent)
window.parent.location.reload();
else
window.location.reload();
}
}
});
};
[/code]