I am designing a GUI. I have an edit text box where I enter a date string with the following format '31 Mar 2011 10:00:00.000'. I need code to validate it and write an error message in case of invalid input. Thank you for your attention. Cheers.
Could you handle this with a regular expression. If you will require your user to input a date with a specific format, I could see parsing this string with the matlab function regexp to see if it matches a given format. In the case you gave above something like
s='31 Mar 2011 10:00:00.000'
regexp(s,'\d{1,2} \w{3} \d{4} \d{2}:\d{2}:\d{2}\.?\d*')
could be used to see if your date matches the format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With