Hi,
I am using this formvalidation https://formvalidation.io/ and I want to check the absenceType to see if the value entered matches a specific string but can’t work out how to do it.
Here is the code I’m currently using and you can see I’m checking to see it’s not empty and I also want to check to see that it doesn’t match a specific string.
<script type="text/javascript">
$(document).ready(function() {
<?php if(isset($_GET['id']) AND $_GET['id'] != "") { ?>
changecat(<?php echo $_SESSION['employee']->absenceCategoryID; ?>);
<?php } ?>
$('#datePicker')
.datepicker({
weekStart: 1, autoclose: true,
format: 'dd/mm/yyyy'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#absenceForm').formValidation('revalidateField', 'absenceStartDate');
});
$('#datePicker2')
.datepicker({
weekStart: 1, autoclose: true,
format: 'dd/mm/yyyy'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#absenceForm').formValidation('revalidateField', 'absenceEndDate');
});
$('#datePicker3')
.datepicker({
weekStart: 1, autoclose: true,
format: 'dd/mm/yyyy'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#absenceForm').formValidation('revalidateField', 'returnInterviewDate');
});
$('#datePicker4')
.datepicker({
weekStart: 1, autoclose: true,
format: 'dd/mm/yyyy'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#absenceForm').formValidation('revalidateField', 'returnNotesSaved');
});
$('#datePicker5')
.datepicker({
weekStart: 1, autoclose: true,
format: 'dd/mm/yyyy'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#absenceForm').formValidation('revalidateField', 'reviewDate');
});
$('#datePicker6')
.datepicker({
weekStart: 1, autoclose: true,
format: 'dd/mm/yyyy'
})
.on('changeDate', function(e) {
// Revalidate the date field
$('#absenceForm').formValidation('revalidateField', 'leaveEvidenceDate');
});
$('#absenceForm').formValidation({
message: 'This value is not valid',
icon: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
absenceStartDate: {
row: '.col-lg-2',
validators: {
notEmpty: {
message: 'The start date is required'
},
date: {
format: 'DD/MM/YYYY',
message: 'The value is not a valid date'
}
}
},
absenceCategory: {
row: '.col-lg-2',
validators: {
notEmpty: {
message: 'The category is required'
}
}
},
duration: {
row: '.col-lg-2',
validators: {
notEmpty: {
message: 'The duration is required'
}
}
},
absenceType: {
row: '.col-lg-2',
validators: {
notEmpty: {
message: 'The type of absence is required'
}
}
},
'paid[]': {
row: '.col-lg-2',
validators: {
notEmpty: {
message: 'The paid field is required'
}
}
},
absenceEndDate: {
row: '.col-lg-2',
validators: {
date: {
format: 'DD/MM/YYYY',
message: 'The value is not a valid date'
}
}
},
returnInterviewDate: {
row: '.col-lg-2',
validators: {
date: {
format: 'DD/MM/YYYY',
message: 'The value is not a valid date'
}
}
},
returnNotesSaved: {
row: '.col-lg-2',
validators: {
date: {
format: 'DD/MM/YYYY',
message: 'The value is not a valid date'
}
}
},
reviewDate: {
row: '.col-lg-2',
validators: {
date: {
format: 'DD/MM/YYYY',
message: 'The value is not a valid date'
}
}
},
leaveEvidenceDate: {
row: '.col-lg-2',
validators: {
date: {
format: 'DD/MM/YYYY',
message: 'The value is not a valid date'
}
}
},
}
});
});
</script>