Verifying date format
<p>I want to verify that the date entered is in yyyy/mm/dd format. If by mistake user enters in dd/mm/yyyy format, it must automatically convert to yyyy/mm/dd using Javascript function.</p>

<p><strong>Edited:</strong></p>

<pre><code>function CheckDateFormat()
{
 EnteredText = document.getElementById('LDate').value;
 LengthOfText = EnteredText.length;
 Status = true;
 for(i=0;i&lt;=LengthOfText;i++)
 {
  currentChar = EnteredText.substr(i,1);
  if (currentChar == '/' &amp;&amp; (i != 5 || i != 8))
  {
   alert("Invalid date format");
   document.getElementById('LDate').focus;
   status = false;
  }
  if (status == false)
   break;
 }
}
</code></pre>
