Adding/removing class question
I have the following code attached to my save button. It looks for textboxes and comboboxes that have requiredText or requiredCombo classes assigned. My problem is that for one of the text boxes, when the user clicks a check box, I use the removeclass function to remove the requiredText class from the text box (I also use the addClass button to add the class back based on the state of the checkbox). But when the save button is clicked it still acts like the text box has the requiredClass class. Is it possible to remove a class (or add it) and have it affect the code as I have attached it to the save button? Or what is the best solution?
// save button verify reqruied text/combo boxes
$('#btnSave').click(function(e) {
var blnSave = 'Y';
$('input[type="text"].requiredText').each(function(){
if (this.value == '' || this.value == 'Required'){
$('#lblUserMessage').text('You must enter all Required items.');
$('#lblUserMessage').css({'color':'red', 'font-size':'125%'});
$(this).css({'color':'red'});
// jqDialog.notify($(this).attr('title'), 10);
jqDialog.notify("<BR />You must enter all REQUIRED items.<BR />Please try again.", 10);
blnSave = 'N';
}
});
$('.requiredCombo').each(function(){
if (this.selectedIndex == 0) {
$('#lblUserMessage').text('You must enter all Required items.');
$('#lblUserMessage').css({'color':'red', 'font-size':'125%'});
$(this).css({'color':'red'});
// jqDialog.notify($(this).attr('title'), 10);
jqDialog.notify("<BR />You must enter all REQUIRED items.<BR /><BR />Please try again.", 10);
blnSave = 'N';
}
});
if (blnSave == 'Y') {
$('#lblUserMessage').text('SAVING ENTRY ... Please wait.');
$('#lblUserMessage').css({'color':'red', 'font-size':'125%'});
jqDialog.notify("<BR />SAVING ENTRY<BR />Please Wait.", 10);
} else {
e.preventDefault();
return false;
}
});
TIA,
John