vgquotes/Src/VideoGameQuotes.Web/media/js/jquery.modelerrors.js
tmont 25172d14a3 * compressed javascript
* renamed css file
* removed copypaste code for js includes
* added pdn files
* changed unused images/javascript build type from Content to None
2011-03-01 00:11:17 +00:00

39 lines
994 B
JavaScript

(function($){
$.fn.applyModelErrors = function(errorMessage, errorData) {
var $this = this;
if (errorMessage !== null) {
$this.find(".error-summary").first().text(errorMessage).show();
}
$.each(errorData, function(inputFieldName, value) {
var $input = $this.find("input[name='" + inputFieldName + "']");
if ($input.length > 1) {
$input = $("#" + inputFieldName);
}
if ($input.length === 1) {
if ($input[0].localName === "INPUT") {
$input.addClass("input-validation-error");
}
$("<span/>")
.addClass("field-validation-error")
.append($("<span/>").addClass("error-icon"))
.append($("<span/>").text(value))
.insertAfter($input);
}
});
return this;
};
$.fn.clearModelErrors = function() {
this
.find(".field-validation-error").remove().end()
.find(".input-validation-error").removeClass("input-validation-error").end()
.find(".error-summary").empty().hide();
return this;
};
}(jQuery));