Validating Date Field using Javascript
<p>I'm just practicing some beginner javascript in hopes of understanding it better. I've created a To Do List and have two questions.</p>

<ol>
<li><p>I'd like to figure out a way when someone hits submit it adds the task to the to do list instead of clearing everything out. So say on 12/8 I have homework due. The on 12/9 I need to pay the bills. Is there a way to add both one at at time without clearing the previous entry. (I have a feeling this has to be done with php and mysql, but i've been wrong many times before).</p></li>
<li><p>Lastly, I'm trying to set it up to where it will validate the Date Due field to make sure the the entry in numbers in the "dd/mm/year" format. I found several examples online, but none that would allow the user to select any future date.</p></li>
</ol>

<p></p>

<pre><code>&lt;form name="list"&gt;
&lt;input type="text" name="datedue" value="Date Due" /&gt; &lt;br /&gt;
&lt;input type="text" name="todo" value="Task" /&gt; &lt;br /&gt;
&lt;input type="button" name="button1"  value="Submit" onclick="addList()"/&gt; &lt;br /&gt;
&lt;/form&gt;
&lt;div id="todolist"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;Due Date &lt;/td&gt;
&lt;td&gt;Task&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;script type="text/javascript"&gt;
function addList() {
    var addDueDate = document.list.datedue.value;
    var addToList = document.list.todo.value;
    document.getElementById("todolist").innerHTML = "&lt;table&gt;&lt;tr&gt;&lt;td&gt; Due Date
&lt;/td&gt;&lt;td&gt;Task&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;" + addDueDate + "&lt;/td&gt;&lt;td&gt; " + addToList + "&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;";
}
var checkDateDue = document.list.datedue;
var checkToDo = document.list.todo;
checkDateDue.onfocus = function() {
    if (checkDateDue.value == "Date Due") {
        checkDateDue.value = "";
    }
}
checkToDo.onfocus = function() {
    if (checkToDo.value == "Task") {
        checkToDo.value = "";
    }
}
checkDateDue.onblur = function() {
    if (checkDateDue.value == "") {
        alert("please enter the due date");
        checkDateDue.value = "Date Due";
    }
}
checkToDo.onblur = function() {
    if (checkToDo.value == "") {
        alert("Please enter your task");
        checkToDo.value = "Task";
    }
}
&lt;/script&gt;
</code></pre>

<p>Thanks.</p>

<p>P.S.  If anyone has any suggestions for some beginner to intermediate javascripts I could practice. Please let me know. My goal is to become a javascript expert. And in my current job, I really don't have to write much js, so it's been hard to get better at it. I'm thumbing through these boards as well to find some that I can do. </p>
