locked
Unhandled exception Math.trunc Javacript Error in IE RRS feed

  • Question

  • User-1355965324 posted

    When I am using the following code , it is shown the error in IE but it is working in chrome

    Unhandled exception at line 221, column 9 in eval code 0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'trunc'

    The code is given below

    <td><input type="text" id="NormalHrs" asp-for="NormalHrs" class="col-sm-5" maxlength="5" 
                                                       onkeypress="return (event.charCode >= 48 && event.charCode <= 57) ||event.charCode == 46 || event.charCode == 0 "
                                                       oninput="Validate(this)"
                                            /></td>
    
     function Validate(e) {
            var t = e.value;
            var tint = Math.trunc(t);
            var tdecimal = t - tint;
            var t1 = t.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0];
            $("#NormalHrs").val(t1);
    
            if (tint > 10) {
                $("#NormalHrs").val(0);
            }
            if (tdecimal > 0.59) {
                $("#NormalHrs").val(tint);
            }
        }

     
    Friday, September 11, 2020 11:38 AM