Monday, 25 February 2013

Validation at least one before and one after decimal



  <asp:TextBox ID="txttotalarea" runat="server"
                                                    Width="90px" onKeyUp="fillareaandunit(this.id);">0</asp:TextBox>



 function fillareaandunit(id) {
            var e = document.getElementById("" + id + "");
            var regexp = ^\d{0,M}\.?\d{0,N}$;
            if (!regexp.test(e.value)) {
                alert("Please enter onyl number.");
                e.value = e.value.substring(0, e.value.length - 1);
                return false;
            }


M = at most number of digits before decimal point
N = at most number of digits after decimal point

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...