I have this bit of code:
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" ID="TextBox1" Text="10/20/2013" onchange="javascript:MyFunc();"></asp:TextBox>
<asp:TextBox runat="server" ID="TextBox2" Text=""></asp:TextBox>
</div>
</form>
<script type="text/javascript">
function MyFunc() {
MyTextBox = document.getElementById("<%= TextBox1.ClientID %>");
MyTextBox2 = document.getElementById("<%= TextBox2.ClientID %>");
var date = new Date(MyTextBox.value);
var day = date.getDate();
var month = date.getMonth() + 1;
var year = date.getFullYear() + 1;
MyTextBox2.value = day + "/" + month + "/" + year;
}
</script>
</body>
Which basically is 2 textboxes and when the first textbox date is updated the second textbox value becomes the date from textbox 1 + 1 year.
The code works fine except for one issue. In Textbox1 the date must be in the US format mm/dd/yyyy which is wrong. For example if I want to change 20/10/2013 into 20/10/2014 I must enter 10/20/2013 in the first textbox.
How can I get it to work for dd/mm/yyyy?