Tuesday, 10 November 2015

JavaScript : Restrict multiple time entry of and char or number or decimal using javascript on keypress



// HTML

<asp:TextBox ID="TextBox1" runat="server"   onkeypress="return isNumber(this, event);">


// JS

<script type="text/javascript">
function Is_Double_Exits(obj, event) {
            debugger;
            var charCode = (event.which) ? event.which : event.keyCode;
            if (charCode == 46) {   // keycode of decimal
                if (obj.value.indexOf('.') === -1) {
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                    return false;
                }
                else {
                    return true;
                }
            }
return true;
        }
</script>

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...