Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
26
rated 0 times [  27] [ 1]  / answers: 1 / hits: 15085  / 11 Years ago, fri, may 31, 2013, 12:00:00

I'm using HTML5 input type=date field and because some browsers still don't support this feature, I would like to create error validation message for browsers that display just normal text field instead of date field. This error message should look like




Please enter date in format: ...




But I need to find the correct format, that the browser is set to. Is there any php/js/jQuery way how to find out this?


More From » html

 Answers
27

Thanks to @Jose Vega's answer I was able to find very easy way how to do it.



     var now=new Date(2013,11,31);
var str=now.toLocaleDateString();
str=str.replace(31,dd);
str=str.replace(12,mm);
str=str.replace(2013,yyyy);


Error message:




Please enter date in format: + str



[#77894] Thursday, May 30, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myakylas

Total Points: 66
Total Questions: 85
Total Answers: 95

Location: Guadeloupe
Member since Sat, Aug 22, 2020
4 Years ago
myakylas questions
Thu, Apr 28, 22, 00:00, 2 Years ago
Thu, Apr 8, 21, 00:00, 3 Years ago
Sat, Sep 19, 20, 00:00, 4 Years ago
;