Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1a53b1

Browse files
committed
Move remote method down the list to run last, after all other methods applied to a field.Fixesjquery-validation#679
1 parent15964e0 commitd1a53b1

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

‎jquery.validate.js

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -998,60 +998,6 @@ $.extend($.validator, {
998998
return$.trim(value).length>0;
999999
},
10001000

1001-
// http://docs.jquery.com/Plugins/Validation/Methods/remote
1002-
remote:function(value,element,param){
1003-
if(this.optional(element)){
1004-
return"dependency-mismatch";
1005-
}
1006-
1007-
varprevious=this.previousValue(element);
1008-
if(!this.settings.messages[element.name]){
1009-
this.settings.messages[element.name]={};
1010-
}
1011-
previous.originalMessage=this.settings.messages[element.name].remote;
1012-
this.settings.messages[element.name].remote=previous.message;
1013-
1014-
param=typeofparam==="string"&&{url:param}||param;
1015-
1016-
if(previous.old===value){
1017-
returnprevious.valid;
1018-
}
1019-
1020-
previous.old=value;
1021-
varvalidator=this;
1022-
this.startRequest(element);
1023-
vardata={};
1024-
data[element.name]=value;
1025-
$.ajax($.extend(true,{
1026-
url:param,
1027-
mode:"abort",
1028-
port:"validate"+element.name,
1029-
dataType:"json",
1030-
data:data,
1031-
success:function(response){
1032-
validator.settings.messages[element.name].remote=previous.originalMessage;
1033-
varvalid=response===true||response==="true";
1034-
if(valid){
1035-
varsubmitted=validator.formSubmitted;
1036-
validator.prepareElement(element);
1037-
validator.formSubmitted=submitted;
1038-
validator.successList.push(element);
1039-
deletevalidator.invalid[element.name];
1040-
validator.showErrors();
1041-
}else{
1042-
varerrors={};
1043-
varmessage=response||validator.defaultMessage(element,"remote");
1044-
errors[element.name]=previous.message=$.isFunction(message) ?message(value) :message;
1045-
validator.invalid[element.name]=true;
1046-
validator.showErrors(errors);
1047-
}
1048-
previous.valid=valid;
1049-
validator.stopRequest(element,valid);
1050-
}
1051-
},param));
1052-
return"pending";
1053-
},
1054-
10551001
// http://docs.jquery.com/Plugins/Validation/Methods/email
10561002
email:function(value,element){
10571003
// contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
@@ -1159,6 +1105,60 @@ $.extend($.validator, {
11591105
});
11601106
}
11611107
returnvalue===target.val();
1108+
},
1109+
1110+
// http://docs.jquery.com/Plugins/Validation/Methods/remote
1111+
remote:function(value,element,param){
1112+
if(this.optional(element)){
1113+
return"dependency-mismatch";
1114+
}
1115+
1116+
varprevious=this.previousValue(element);
1117+
if(!this.settings.messages[element.name]){
1118+
this.settings.messages[element.name]={};
1119+
}
1120+
previous.originalMessage=this.settings.messages[element.name].remote;
1121+
this.settings.messages[element.name].remote=previous.message;
1122+
1123+
param=typeofparam==="string"&&{url:param}||param;
1124+
1125+
if(previous.old===value){
1126+
returnprevious.valid;
1127+
}
1128+
1129+
previous.old=value;
1130+
varvalidator=this;
1131+
this.startRequest(element);
1132+
vardata={};
1133+
data[element.name]=value;
1134+
$.ajax($.extend(true,{
1135+
url:param,
1136+
mode:"abort",
1137+
port:"validate"+element.name,
1138+
dataType:"json",
1139+
data:data,
1140+
success:function(response){
1141+
validator.settings.messages[element.name].remote=previous.originalMessage;
1142+
varvalid=response===true||response==="true";
1143+
if(valid){
1144+
varsubmitted=validator.formSubmitted;
1145+
validator.prepareElement(element);
1146+
validator.formSubmitted=submitted;
1147+
validator.successList.push(element);
1148+
deletevalidator.invalid[element.name];
1149+
validator.showErrors();
1150+
}else{
1151+
varerrors={};
1152+
varmessage=response||validator.defaultMessage(element,"remote");
1153+
errors[element.name]=previous.message=$.isFunction(message) ?message(value) :message;
1154+
validator.invalid[element.name]=true;
1155+
validator.showErrors(errors);
1156+
}
1157+
previous.valid=valid;
1158+
validator.stopRequest(element,valid);
1159+
}
1160+
},param));
1161+
return"pending";
11621162
}
11631163

11641164
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp