jQuery EasyUI Form - Form Validation
This tutorial will show you how to validate a form. The easyui framework provides a validatebox plugin to validate a form. In this tutorial, we will create a contact form and apply the validatebox plugin to validate it. You can then adjust the form to suit your needs.
Creating the form
Let's create a simple contact form with name, email, subject, and message fields:
Form Validation
We add a class named easyui-validatebox to the input tags, so the input tags will apply validation according to the validType property.
Preventing form submission when the form is invalid
When the user clicks the form's submit button, if the form is invalid, we should prevent the form from being submitted.
$('#ff').form({
url:'form3_proc.php',
onSubmit:function(){
return $(this).form('validate');
},
success:function(data){
$.messager.alert('Info', data, 'info');
}
});
If the form is invalid, a prompt message will be displayed.