title: Check the value of the field in HH:MM format using ajax javascript
body: <p>I have a field <em>HrsBirthDate</em> which should take input in format HH:MM (it can be 00:01, 01:19, 23:44, 19:34, 13:12).</p>
  <p>So before submitting the form I need to check whether the value is in any of the above formats else throw an error message.</p>
  <p>Now only I can check that the field is not empty.</p>
  <p>This is my code:</p>
  <pre><code>        $(&quot;body&quot;).on(&quot;click&quot;, &quot;#WebGrid TBODY .Update&quot;, function () {
             var row = $(this).closest(&quot;tr&quot;);
             var employee = {};
             employee.EmployeeID = row.find(&quot;.EmployeeId&quot;).find(&quot;.label&quot;).html();
             employee.FirstName = row.find(&quot;.Name&quot;).find(&quot;.text&quot;).val();
             employee.BirthDate = row.find(&quot;.DOB&quot;).find(&quot;.text&quot;).val();
             employee.HrsBirthDate = row.find(&quot;.HrsBirthDate&quot;).find(&quot;.text&quot;).val();
   
             if (employee.FirstName != '' &amp;&amp; employee.BirthDate != '' &amp;&amp; employee.HrsBirthDate != '') {
                 debugger;
                 $(&quot;td&quot;, row).each(function () {
                     if ($(this).find(&quot;.text&quot;).length &gt; 0) {
                         var span = $(this).find(&quot;.label&quot;);
                         var input = $(this).find(&quot;.text&quot;);
                         span.html(input.val());
                         span.show();
                         input.hide();
                     }
                 });
                 row.find(&quot;.Edit&quot;).show();
                 row.find(&quot;.Cancel&quot;).hide();
                 $(this).hide();
                 $.ajax({
                     type: &quot;POST&quot;,
                     url: &quot;/Home/UpdateEmployee&quot;,
                     data: '{employee:' + JSON.stringify(employee) + '}',
                     contentType: &quot;application/json; charset=utf-8&quot;,
                     dataType: &quot;json&quot;
                 });
             }
             else {
                 alert(&quot;Please fill the details.&quot;);
                 return false;
             }
         });
  </code></pre>