You must Sign In to post a response.
  • Category: JQuery

    Hi all how to check validation for time

    hi all below is my code
    what i want is if i enter in textbox like time gretaer than 23:59 then alert should come i have written but no alert

    @Html.Editor(" ", new { htmlAttributes = new { @class = "", maxlength = 35,@id= "etdtime", @Name ="etdtime", @onchange = "checketd()" } })

    function checketd()
    {




    var splittime = $("#etdtime").val();

    if(splittime[0] > 22 && splittime[1] > 58) {
    alert('please enter a valid date'); return false;
    }

    }
  • #769548

    Rather than doing this kind of splitting condition just try to convert the entered value into "Date" format. If it is converted then it is valid otherwise just throw an alert message like the invalid date. Refer the simple code,

    function checketd()
    {
    try
    {
    var splittime = new Date($("#etdtime").val());
    }catch(ex)
    {
    alert('please enter a valid date'); return false;
    }
    return true;
    }


    Regards,
    V.M. Damodharan
    "Your talent will be worthless, when you have fear and tension."

  • #769723

    pl check below url and validaion.js might be useful for your requirement.

    https://validatejs.org/


    Thanks!
    B.Ramana Reddy


  • Sign In to post your comments