cogido para validar cajas de texto.
Código PHP:
function evalFieldset(){
var count = 0;
//Get the required fields for TextAreas and Inputs and Selects
var fields = $("input.required, select.required, textarea.required");
if (fields.length > 0 ){
$.each(fields, function(){
if ($(this).val().length == 0 ){
$(this).css({'background-color' : '#FFF2DF', 'border' : '1px solid #FF9900'});
count = count + 1;
} else {
$(this).css({'background-color' : '#FFF', 'border' : '1px solid #CCC'});
}
});
if (count != 0){
return 'not go';
} else {
return 'go';
}
} else {
return 'go';
}
}
Código PHP:
function evalRadio(){
//Get the required fields for TextAreas and Inputs and Selects
var fields = $("input[class='required']:radio");
$.each(fields, function(){
if ($(this).is(':checked'))
$(this).parent().css({'background-color' : '#FFF2DF', 'border' : '1px solid #FF9900'});
} else {
$(this).parent().css({'background-color' : '#FFF', 'border' : '1px solid #CCC'});
}
});
}