i want to create DateTimeAttribute like that:
public class DateTimeAttribute : RegularExpressionAttribute
{
public DateTimeAttribute(): base(@"\d\d.\d\d.\d\d\d\d")
{
}
}
i want to make my format: dd.mm.yyyy it is too simple but:
^((((0?[1-9]|[12]\d|3[01]).-/.-/)|((0?[1-9]|[12]\d|30).-/.-/)|((0?[1-9]|1\d|2[0-8])[.-/]0?2.-/)|(29[.-/]0?2.-/))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$
it is too diffucult also not working? how to parse dd.mm.yyyy in my regex expression?
Try:
But this will match invalid dates like February 31st. So you’ll need to check validity of the date anyway.