Skip to main content

dates change by itself

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2014-06-08

<script type="text/javascript">

function CompareDates(id)

var monName = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec");

var d = new Date(id);

var curr_date = d.getDate();

var curr_month = d.getMonth();

var curr_year = d.getFullYear();

return (curr_date + " " + monName[curr_month] + " " + curr_year);


and then this calendar tag:



pattern="d MMM, yyyy"


onchange="$(this).val(CompareDates($(this).val())) "



and for some unknown reason i don't know why the default date format that the textbox accepts is in 'mm/dd/yyyy'

For example if i entered "13-05-2014" then it would return an error stating date is invalid.

If i entered "12-05-2014" then it would return "5 Dec, 2014"

I did not declare any dateformat anywhere except for the datepickers which as shown above, is 'd MMM, yyyy'

Before this happened i trialed and error many different kind of codes to try to validate the date however it all didnt work and so i reverted it all back to the original codes.

Last time the dateformat that the textbox accepted was 'dd/mm/yyyy' and it worked fine with my javascript function except the validation part.

Now it still works except that the dateformat changed to 'mm/dd/yyyy'.

I did try to use console.log to find out what's wrong but there were no error messages.

could anyone help me and tell me what is going on here?

Why has the dateformat changed by itself?