weide escribió: > I Search the web and found code like down: > ---------------------------------------- > > 2. Can one validate date formats form other countries like Germany? > > This is a YAV config setting, by example Spain date format is > dd-MM-yyyy, so in the second map param > of the plugin I can set the YAV settings (see YAV reference): > $("#myform").yav({ > onError:function(){ > $("#errorContainer").append($(".error")); //Append all the > error > messages > $(".error").not($("#errorContainer .error")).remove(); // > Remove > all the old errors but not in the errorContainer > } > }, > > //Yav preferences in a second map object param > { > DATE_FORMAT: 'dd-MM-yyyy' > > }); > -------------------------------------------------------- > > But I have a problem.I set the DATE_FORMAT=yyyy-MM-dd > so "2007-09-26" is ok,but 2007-9-26 is not OK. > > set yyyy-M-d,it seems not work > > > Sorry but YAV original documentation is not very clear. The date codes only are: yyyy: for the year MM: for the months dd: for the days
You can use, alternatelly a regular expression "^([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]?([0]?[1-9]|[1][0-2])[./-]?([0-9]{4}|[0-9]{2})$" with the rule "regexp", example: <input name="test" id="test" class="regexp" title="Write a valid date" alt="{param:'^([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]?([0]?[1-9]|[1][0-2])[./-]?([0-9]{4}|[0-9]{2})$'}" /> This regexp valid 09-05-2007, 9/4/2007, 12/03/08 If you need to validate dates in year-month-day this regular expression is that you need. ^([0-9]{4}|[0-9]{2})?([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]?([0]?[1-9]|[1][0-2])[./-]$ -- Best Regards, José Francisco Rives Lirola <sevir1ATgmail.com> SeViR CW ・ Computer Design http://www.sevir.org Murcia - Spain