Validation for purpose select box working

This commit is contained in:
2013-03-03 20:43:13 -05:00
parent e911dfced7
commit 9f0e5f7b1d
6 changed files with 30 additions and 20 deletions
+18 -9
View File
@@ -187,16 +187,17 @@ $(function() {
* The errors are produced by the MVC unobtrusive validation.
*/
$(function () {
var errorSelector = 'span.field-validation-error, .input-validation-error';
$('form').submit(function () {
$(this).find('div.control-group').each(function () {
if ($(this).find('span.field-validation-error').length == 0) {
if ($(this).find(errorSelector).length == 0) {
$(this).removeClass('error');
}
});
if (!$(this).valid()) {
$(this).find('div.control-group').each(function () {
if ($(this).find('span.field-validation-error').length > 0) {
if ($(this).find(errorSelector).length > 0) {
$(this).addClass('error');
}
});
@@ -204,7 +205,7 @@ $(function () {
});
$('form').each(function () {
$(this).find('div.control-group').each(function () {
if ($(this).find('span.field-validation-error').length > 0) {
if ($(this).find(errorSelector).length > 0) {
$(this).addClass('error');
}
});
@@ -213,14 +214,22 @@ $(function () {
//Update that validator
if ($.validator === undefined)
return;
$.validator.setDefaults({
highlight: function (element) {
$(element).closest(".control-group").addClass("error");
highlight: function(element) {
if (element.type === 'radio') {
this.findByName(element.name).closest(".control-group").addClass("error");
} else {
$(element).closest(".control-group").addClass("error");
}
},
unhighlight: function (element) {
$(element).closest(".control-group").removeClass("error");
},
debug: true
unhighlight: function(element) {
if (element.type === 'radio') {
this.findByName(element.name).closest(".control-group").removeClass("error");
} else {
$(element).closest(".control-group").removeClass("error");
}
}
});
});