You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.0 KiB

$(function() {
$("#username").blur(
function() {
$("#username_msg").empty();
var name = $(this).val();
if (name == "" || name == null) {
$("#username").after("<span id='username_msg' style='color: red'>用户名不能为空</span>");
}
});
$("#password").blur(
function() {
$("#password_msg").empty();
var name = $(this).val();
if (name == "" || name == null) {
$("#password").after("<span id='password_msg' style='color: red'>密码不能为空</span>");
}
});
$("#realname").blur(
function() {
$("#realname_msg").empty();
var name = $(this).val();
if (name == "" || name == null) {
$("#realname").after("<span id='realname_msg' style='color: red'>姓名不能为空</span>");
}
});
$("#contact").blur(
function() {
$("#contact_msg").empty();
var name = $(this).val();
if (name == "" || name == null) {
$("#contact").after("<span id='contact_msg' style='color: red'>联系方式不能为空</span>");
}
});
$('#sub').click(function(){
var username = $("#username").val();
var password = $("#password").val();
var realname = $("#realname").val();
var contact = $("#contact").val();
$("#username_msg").empty();
$("#password_msg").empty();
$("#realname_msg").empty();
$("#contact_msg").empty();
if (username == "" || username == null) {
$("#username").after("<span id='username_msg' style='color: red'>用户名不能为空</span>");
return false;
}
if (password == "" || password == null) {
$("#password").after("<span id='password_msg' style='color: red'>密码不能为空</span>");
return false;
}
if (realname == "" || realname == null) {
$("#realname").after("<span id='realname_msg' style='color: red'>姓名不能为空</span>");
return false;
}
if (contact == "" || contact == null) {
$("#contact").after("<span id='contact_msg' style='color: red'>联系方式不能为空</span>");
return false;
}
});
$('#res').click(function() {
$("#username_msg").empty();
$("#password_msg").empty();
$("#realname_msg").empty();
$("#contact_msg").empty();
});
});