Date Validation between two date fields

Date Validation between two date fields

Do you have an example of date fields validation? I have two date fields (from, to). I would like to check if the date in FROM field is earlier of the To field then it's ok...If the date is after or same to To field then give an error message. I know how to do it in javascript but I do not know if it is possible to do it here.