 I want to validate when time selected from drop down list is past current time
<p>I'm new to java script. I want to validate wether the time selected from drop down list is past the current time. </p>

<p>For example:<br>
The user selects <code>2:00pm</code> while the current time is <code>1:00pm</code>, now the following error should popup:</p>

<blockquote>
  <p>The time you have selected is before the current time.</p>
</blockquote>

<p>How can I do this? Below is my drop down list.</p>

<pre><code>&lt;?php
$start = strtotime('12:00am');
$end = strtotime('11:30pm');

echo '&lt;select name="time"&gt;';
for ($i = $start; $i &lt;= $end; $i += 1800)
{
    echo '&lt;option&gt;' . date('g:i a', $i);
}
echo '&lt;/select&gt;';


?&gt;
</code></pre>

<p>I have tried the following however I could not make this working. </p>

<pre><code>    &lt;script type="text/javascript" language=JavaScript&gt;
function validate_time(elmnt)
{
    var date_in = new date(elmnt);
    var date_now = new date(); //returns current date by default;
    if( date_in&lt;date_now ){ alert('The time you have selected is before the current time.');
}   
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;



&lt;div align="left"&gt;
&lt;?php


$start = strtotime('12:00am');
$end = strtotime('11:30pm');

echo '&lt;select name="time"&gt;';
for ($i = $start; $i &lt;= $end; $i += 1800)
{
echo '&lt;option&gt;' . date('g:i a', $i);
}
echo '&lt;select name=time onchange="OnChange(this.form.select)"&gt;';
echo '&lt;/select&gt;';

?&gt;
</code></pre>
