SinkDark/myblog/publicStatic/js/user.js
2024-09-17 17:30:58 +08:00

36 lines
823 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

$(function(){
$('#username').focus().blur(checkName);
$('#password').blur(checkPassword);
});
function checkName(){
var name = $('#username').val();
if(name == null || name == ""){
//提示错误
$('#count-msg').html("不能为空哦!");
return false;
}
var reg = /^\w{3,10}$/;
if(!reg.test(name)){
$('#count-msg').html("输入3-10个字母或数字或下划线");
return false;
}
$('#count-msg').empty();
return true;
}
function checkPassword(){
var password = $('#password').val();
if(password == null || password == ""){
//提示错误
$('#password-msg').html("密码不能为空");
return false;
}
var reg = /^\w{3,10}$/;
if(!reg.test(password)){
$('#password-msg').html("输入3-10个字母或数字或下划线");
return false;
}
$('#password-msg').empty();
return true;
}