Changes

Date Validation

922 bytes added, 19:21, 19 March 2014
no edit summary
}
}
 
function fn_CheckDOBFormat( strField ){
 
var objField = document.getElementById(strField);
var aryDOBInForm = objField.value.split('/');
var strErrorsFound = 'None';
if(aryDOBInForm.length != 3){
strErrorsFound = 'Date Of Birth entered is not in the format DD/MM/YYYY';
}
if(aryDOBInForm[1] > 12){
strErrorsFound = 'Date Of Birth entered is not in the format DD/MM/YYYY';
}
if(aryDOBInForm[0].length != 2){
strErrorsFound = 'Date Of Birth entered is not in the format DD/MM/YYYY';
}
if(aryDOBInForm[1].length != 2){
strErrorsFound = 'Date Of Birth entered is not in the format DD/MM/YYYY';
}
if(aryDOBInForm[2].length != 4){
strErrorsFound = 'Date Of Birth entered is not in the format DD/MM/YYYY';
}
if(strErrorsFound != 'None'){
alert(strErrorsFound);
objField.value = '';
objField.setAttribute('placeholder','Please enter a date in the format DD/MM/YYYY');
}
}
 
 
</source>
7,528
edits