Var accErrorMsg = "Enter the customer category name ";
// Verify form data
$ (Function (){
// $. FormValidator. initConfig ({formid: "myform", autotip: true });
$. FormValidator. initConfig ({
Formid: "myform ",
Autotip: true
});
$ ("# Name"). formValidator ({
Onshow: "Enter the customer category name ",
Onfocus: "2 to 20 characters ",
Oncorrect: "correct input"}). functionValidator ({
Fun: function (){
Var roleName = $ ("# name"). val ();
If (trim (roleName) = "")
{
AccErrorMsg = "Enter the customer category name ";
Return accErrorMsg;
} Else if (trim (roleName). length = 1 | trim (roleName). length> 20 ){
AccErrorMsg = "2 to 20 characters ";
Return accErrorMsg;
}
Else
{
Return true;
}
}
}). AjaxValidator ({
Type: "post ",
Url: "$ {basePath} clientSortSTManage/clientSortST! IsClientSortNameExist. action ",
Datatype: "json ",
Timeout: 3000,
Success: function (data)
{
// Compare the old role name with the new role name.
Var oldName = $ ('# oldname'). val ();
Var rName = $ ('# name'). val ();
If (oldName & oldName = rName)
{
Return true;
}
// Determine based on ajax return results
Var correct = data. correct;
If (correct)
{
Return true;
}
Else
{
Return false;
}
},
Error: function ()
{
Artalert ("the service is busy. Please try again later! ");
},
Onerror: "The customer category name already exists. Please change the customer category name ",
Onwait: "The customer category name is being verified. Please wait... "
}). DefaultPassed ();
})
This article is from the "Coffee Hou ye" blog