官网:https://semantic-ui.com/
github: https://github.com/semantic-org/semantic-ui
1、阻止表单submit默认提交,取消掉div的submit类以后,验证会失效,所以按钮或者div必须带有submit类
$('.ui.form').form({
on: 'blur',
fields: {
email: {
identifier : 'email',
rules: [
{
type : 'empty',
prompt : '请输入邮箱'
},
{
type : 'email',
prompt : '请输入正确的邮箱'
}
]
},
password: {
identifier : 'password',
rules: [
{
type : 'empty',
prompt : '请输入密码'
}
]
}
},onSuccess:function (event, fields) {
//清除默认事件
event.preventDefault();
var email = $('#email').val();
var pass = $('#password').val();
$.ajax({
url:'index.php',
type:'post',
data:{
action:'login',
email:email,
password:pass
},success:function (data) {
//请求成功做的一些事情
console.log(data);
}
}
})
}
});