Date validation for dhtmlxcombo box

I wondered if it was possible to validate a dhtmlxcombo box so that any text typed into it HAS to be a valid callendar date. Or apply some kind of a ‘date mask’ to it perhaps?



Basically, I want my dhtmlxcombo box to give the opportunity for a user to EITHER enter a specific date OR select from the dropdown list (on the dhtmlxcombo box) options like ‘Flexible’ or ‘To Be Announced’. These pre-defined options will have date values like 11/11/3011 or 12/12/3012 associated with them.



However, I want to ensure that if a date is manually entered by the user it is validated as a legitimate callendar date.



Do you have any suggestions/soltions?



Many thanks,

Graham.

It is better to validate value when user already pressed enter - onChange event occured.

For example:

combo.attachEvent(“onChange”,function(){
    var text = combo.getComboText();
    if(…){ /here you can check the text; if it is not a correct date the next code will be called/
        combo.setComboValue(""); /clears the actual value/
        combo.setComboText(text); /sets text (not the value) to give user an opportunity to change it/
        alert(“Please, enter the correct date”);    
    }
})