- var accErrorMsg = "請輸入客戶分類名稱";
- //表單數據驗證
- $(function(){
- //$.formValidator.initConfig({formid:"myform",autotip:true});
- $.formValidator.initConfig({
- formid:"myform",
- autotip:true
- });
- $("#name").formValidator({
- onshow:"請輸入客戶分類名稱",
- onfocus:"2至20個字符",
- oncorrect:"輸入正確"}).functionValidator({
- fun: function(){
- var roleName = $("#name").val();
- if(trim(roleName)=="")
- {
- accErrorMsg = "請輸入客戶分類名稱";
- return accErrorMsg;
- }else if(trim(roleName).length==1 ||trim(roleName).length>20){
- accErrorMsg="2至20個字符";
- return accErrorMsg;
- }
- else
- {
- return true;
- }
- }
- }).ajaxValidator({
- type:"post",
- url: "${basePath}clientSortSTManage/clientSortST!isClientSortNameExist.action",
- datatype: "json",
- timeout: 3000,
- success: function(data)
- {
- //將老角色名與新角色名比較,若是同樣判爲經過
- var oldName = $('#oldName').val();
- var rName = $('#name').val();
- if(oldName && oldName==rName)
- {
- return true;
- }
- //根據ajax返回結果判斷
- var correct = data.correct;
- if(correct)
- {
- return true;
- }
- else
- {
- return false;
- }
- },
- error: function()
- {
- artalert("服務繁忙,請稍後再試!");
- },
- onerror : "客戶分類名稱已存在,請更換客戶分類名稱",
- onwait : "正在對客戶分類名稱進行校驗,請稍候…"
- }).defaultPassed();
- })