All jQuery Codes

jQuery code to allow only numbers in textbox

Below jQuery code snippets will allow only numbers in the textbox. However backspace and delete keys are also allowed. $(document).ready(function(){ $("#<%= txtNumbers.ClientID%>").keydown(function(e) { if (e.shiftKey) e.preventDefault(); else { var nKeyCode = e.keyCode; //Ignore Backspace and Tab keys if (nKeyCode == 8 || nKeyCode == 9) return; if (nKeyCode < 95) { if (nKeyCode < 48 […]
Read the rest of this entry »

How to make readonly textbox using Jquery

Sometimes making a textbox readonly is project need. There are 2 ways to make textbox readonly using jQuery. Method 1: <script type="text/javascript"> $(document).ready(function(){ $("#<%=txtName.ClientID %>").focus(function () { $(this).blur(); }); }); </script> See live Demo and Code Method 2: <script type="text/javascript"> $(document).ready(function(){ $("#<%=txtName.ClientID %>").attr('readonly', true); }); </script> Feel free to contact me for any help related […]
Read the rest of this entry »

Responsive Menu
Add more content here...