Archive for June, 2010

Call jQuery from Javascript function

Have you ever come accross a situation where you need to call Jquery from or within a Javascript function? Well, it's not that tough either. You can directly write your jQuery code within a JavaScript function. See below code. I have placed a button on my page which makes a call to a Javascript function […]
Read the rest of this entry »

Using trim() function in jQuery

jQuery also have trim function like javascript trim, which removes spaces from starting and from end of the string. See below code. <script type="text/javascript"> $(document).ready(function(){ var str = " I Love jQuery "; str = jQuery.trim(str); alert(str); }); </script> Output of this would be "I Love jQuery". trim function only removes spaces from starting and […]
Read the rest of this entry »

Split function in jQuery

jQuery provides a method "split()", which splits the text. We can use any delimiter to split the text. Let me explain you with an example. Earlier I had posted about jQuery solution to replace string, substring, trim string and about all string functions, And In this post, see jQuery/JavaScript split function in action with example. […]
Read the rest of this entry »

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 »

A jQuery UI Combobox: Under the hood

Update on 2010-08-17: This article was updated to reflect the changes to the combobox code in jQuery UI 1.8.4 The jQuery UI 1.8 release brings along the new autocomplete widget. An autocomplete adds a list of suggestions to an input field, displayed and filtered while the user is typing. This could be attached to a […]
Read the rest of this entry »

Responsive Menu
Add more content here...