Validation for purpose select box working
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user