SinkDark/myblog/static/js/user.js

36 lines
823 B
JavaScript
Raw Normal View History

2024-09-17 17:30:58 +08:00
$(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;
}