Q: Adding validation for date forms I'm fairly new to javascript, so just looking for a bit of help with adding validation to a form (purely JS/jquery only):
Let's say I have the form getByID("text")
I want to add the validation to stop users entering a decimal place (whole numbers only), no letters or special characters (numbers only), value must not exceed 23 hours/59 minutes (two separate fields for HH:MM (so one must not exceed 23 hours, the other 59 minutes - see below)).
getByID("HH")


*

*must not exceed digit 23 so 0-23 is allowed, no special chars/decimals/letters


getByID("MM")


*

*must not exceed digit 59 so 0-59 is allowed, no special chars/decimals/letters


If anyone could help with this, it would be greatly appreciated. Thanks in advance!

A: <input type="" name="" id="hh" onkeyup="isNumber(event)" placeholder="HH">
<input type="" name="" id="mm" onkeyup="isNumber(event)" placeholder="MM">


<script type="text/javascript">
    function isNumber(evt) {
    var id = evt.target.id;
    var val = $("#"+id).val();
    if (val)
    {
        var numericReg = /^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/;
        if(!numericReg.test(val)) {
            $("#"+id).val('');
            alert('Numeric characters only');
        }
        else
        {
            if (id == 'hh')
            {
                if (val > 24)
                {
                    $("#"+id).val('');
                    alert('Less than 24');
                }
            }
            if (id == 'mm')
            {
                if (val > 60)
                {
                    $("#"+id).val('');
                    alert('Less than 60');
                }
            }
        }
    }    
}
</script>

