First of all, I am not a programmer... rather designer. I know this should be simple but still need a help. I have a form with 2 date fields (date1 and date2). Something like this: <form id="form1" name="form1" method="post" action=""> <input name="date1" type="text" id="date1" /> <input name="date2" type="text" id="date2" /> <input type="submit" name="Submit" value="Submit" /> </form> What I need is to assign value of date1 to date2 IF a valid date is entered into date1... or to assign some date in the far future to date2 IF nothing is entered into date1 (needed for determining sort order upon date2... can't stay blank, unlike date1). I know it should be done through JavaScript. How do I do that?
<html> <head> <title>Title</title> <script type="text/javascript"> function cfunc() { document.getElementById("date2").value=document.getElementById("date1").value } </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <input name="date1" type="text" id="date1" onkeyup="cfunc()"/> <input name="date2" type="text" id="date2" /> <input type="submit" name="Submit" value="Submit" /> </form> </body> </html> HTML: