愉快的一天每个人..我在我的PHP文件中有这个java脚本代码,其中我使用它作为我的验证器…在我的文本框中的不同字段中的输入…我唯一的问题是我不知道如何创建验证只接受信件…在我的名字和姓氏字段…期待任何帮助感谢有一个美好的一天…我也想知道如何只在我的领域接受数字超级谢谢^^,
这是代码:
<script type='text/javascript'>
$(document).ready(function()
{
$('#employee_form').validate({
submitHandler:function(form)
{
$(form).ajaxSubmit({
success:function(response)
{
tb_remove();
post_person_form_submit(response);
},
dataType:'json'
});
},
errorLabelContainer: "#error_message_Box",
wrapper: "li",
rules:
{
first_name: "required",
last_name: "required",
username:
{
required:true,
minlength: 5
},
password:
{
<?PHP
if($person_info->person_id == "")
{
?>
required:true,
<?PHP
}
?>
minlength: 8
},
repeat_password:
{
equalTo: "#password"
},
email:
{
required:true,
email: "email"
}
},
messages:
{
first_name: "<?PHP echo $this->lang->line('common_first_name_required'); ?>",
last_name: "<?PHP echo $this->lang->line('common_last_name_required'); ?>",
username:
{
required: "<?PHP echo $this->lang->line('employees_username_required'); ?>",
minlength: "<?PHP echo $this->lang->line('employees_username_minlength'); ?>"
},
password:
{
<?PHP
if($person_info->person_id == "")
{
?>
required:"<?PHP echo $this->lang->line('employees_password_required'); ?>",
<?PHP
}
?>
minlength: "<?PHP echo $this->lang->line('employees_password_minlength'); ?>"
},
repeat_password:
{
equalTo: "<?PHP echo $this->lang->line('employees_password_must_match'); ?>"
},
email:
{
required: "<?PHP echo $this->lang->line('common_email_name_required'); ?>",
email: "<?PHP echo $this->lang->line('common_email_invalid_format'); ?>"
}
}
});
});
</script>
解决方法:
只有字母:/ ^ [a-zA-Z] $/或/ ^ [a-z] $/ i
只有数字:/ ^ [0-9] $/