`

js jaxt 及各种验证

 
阅读更多

/**

 * 全局变量

 */

var guigeflagword=false;

var guigeflagpc=false;

 

$(function() {

// 获取url地址用来让用户登录时跳转

var windowsurl = window.location;

$('#hidurl').attr("value", windowsurl);

});

 

/**

 * 注册用户激活用户

 */

$(function(){

var uid=$.query.get('uid');

 if(uid!=""){

 $.post("updateUserstate.action",{"uid":uid},function(data){

if(data.sucflag){

alert("用户激活成功,请重新登陆.");

}else{

alert("非法操作,请重新激活.");

}

});

}

});

 

/**

 * 

 */

$(function(){

$.post("findUserHeadById.action",function(data){

if(data.head.headpath!=null){

$('#fileChecker').attr("src",data.head.headpath);

}

});

});

/**

 * 异步获取登录的用户名

 */

function findUsernameSession(){

$.post("findUsernameFromSession.action",function(data){

if(data.username!=""){

$("#welcomeusername").html("你好["+data.username+"]");

}

 

});

}

 

/**

 * 异步获取登录的用户名

 */

function findUsernameSession(){

$.post("findUsernameFromSession.action",function(data){

if(data.username!=""){

$("#welcomeusername").html("你好["+data.username+"]");

}

 

});

}

 

/**

 * 顶级搜索

 */

$(function(){

$('#searchgoods').click(function(){

var topKeywords= $('#topKeywords').val();

var rp=1;

if(topKeywords==""){

return false;

}else{

window.location.href="searchGoodsByGoodsName.action?topKeywords="+topKeywords+"&page=1";

}

//$.post("searchGoodsByGoodsName.action",{"topKeywords":topKeywords,"rp":rp});

return true;

});

});

$(function(){

//// 所在地插件

//$("#ChinaArea").jChinaArea( {

//aspnet : false,

//s1 : "上海市",// 默认选中的省名

//s2 : "上海市",// 默认选中的市名

//s3 : "黄浦区"// 默认选中的县区名

//});

});

var flag = false;

// 验证商品传递的参数

function validatethenpostinfotoaddgoods() {

var username = $('#username').val();

var password = $('#password').val();

var rpassword = $('#rpassword').val();

var email = $('#email').val();

var rand = $('#rand').val();

var random = $('#random').val();

if (username == "") {

alert("用户名必须填写");

return false;

}

if (password == "") {

alert("密码必须填写");

return false;

}

if (password < 4 && password > 20) {

alert("密码必须为6 - 20 之间");

return false;

}

if (rpassword == "") {

alert("请重复密码");

return false;

}

if (rpassword != password) {

alert("两次填写密码不一致");

return false;

}

if (email == "") {

alert("邮箱必须填写");

return false;

}

if (rand == "") {

alert("验证码必须填写");

return false;

}

if (/^[0-9a-z][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}[0-9a-z].){1,4}[a-z]{2,4}$/.test(email)) {

} else {

alert("邮箱格式不正确,请重新填写");

return false;

}

flag = true;

}

 

/*

 * ===========================================Gorgeous

 * split-line==============================================

 */

 

/**

 * 用户注册验证

 */

function clearMsg(val) {

switch (val) {

case 1:

$("#usernameMsg").html("");

break;

case 2:

$("#passwordMsg").html("");

break;

case 3:

$("#EmailMsg").html("");

break;

case 4:

$("#validateCodeMsg").html("");

break;

}

}

/**

 * 用户注册页部分js

 */

$(function() {

var msg=$.query.get('msg');

if (msg != "") {

$("#usernameMsg").html("");

$("#passwordMsg").html("");

$("#EmailMsg").html("");

$("#passwordMsg").html("");

$("#activeemailmsg").html("");

$("#validateCodeMsg").html("");

switch (msg) {

case 1:

$("#usernameMsg").html("<span style='color:red;'>6-20位字符,可由中文、英文、数字及“_”组成</span>");

break;

case 2:

$("#passwordMsg").html("<span style='color:red;'>密码请设为6-16为字母或数字</span>");

break;

case 3:

$("#EmailMsg").html("<span style='color:red;'>邮箱必须填写邮箱地址,如yourName@163.com</span>");

break;

case 4:

$("#usernameMsg").html("<span style='color:red;'>用户已经存在</span>");

break;

case 5:

$("#validateCodeMsg").html("<span style='color:red;'>验证码错误</span>");

break;

case 6:

$("#activeemailmsg").html("<span style='color:red;;font-size: 11pt'>激活邮件已经发送,请激活用户.</span>");

break;

case 7:

$("#EmailMsg").html("<span style='color:red;'>邮箱已经被使用<span>");

break;

}

}

});

 

/*

 * ===========================================Gorgeous

 * split-line==============================================

 */

 

//修改密码

$('#changePasswordsubmit').click(function() {

var oldPassword = jQuery.trim($('#oldPassword').val());

var newPassword = jQuery.trim($('#newPassword').val());

var confirmPassword = jQuery.trim($('#confirmPassword').val());

 

if (oldPassword == ""||newPassword == ""||confirmPassword == "") {

$('#showMsg1').css("visibility", "visible");

$('#showMsg1').html("请输入密码");

return false;

}

if (newPassword.length < 6 || newPassword.length > 20) {

$('#showMsg1').css("visibility", "visible");

$('#showMsg1').html("密码必须为6 - 20 之间");

return false;

}

if (newPassword!=confirmPassword) {

$('#showMsg1').css("visibility", "visible");

$('#showMsg1').html("两次输入的密码不正确");

return false;

}

 $.post("updateUserPassword.action", {

"oldPassword" : oldPassword,

"newPassword" : newPassword,

"confirmPassword":confirmPassword

}, function(data) {

if (data.sucflag) {

$('#showMsg1').css("visibility", "visible");

$('#showMsg1').html("修改密码成功");

} else {

$('#showMsg1').css("visibility", "visible");

$('#showMsg1').html("旧密码不正确");

}

});

});

 

 

 

//设置修改密码保护

$('#questionprotectsubmit').click(function() {

var question = $('#question').val();

if (question == "") {

$('#showMsg1').css("visibility", "visible");

$('#showMsg1').htm

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics