Validate login by pressing enter key $(“#username, #password”).keydown(function(event) { // track enter key var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode)); if ( keycode == 13) { // key code for enter key // force the keyboard ‘Enter Key’ to implicitly click the Update button validateLogin(); return false; } else …
Category: jQuery
How to write a jQuery function
jQuery function jQuery is a type of JavaScript programming script used in website development. jQuery is very strict in its syntax .Programmers are writing jQuery functions for doing specific tasks. Syntax of JQuery function is //start <script type=”text/javascript”> $(“#username”).keydown(function(event) { }); </script> //end function This is a keydown function
How to loop through array in jquery
if(jQuery.trim(jQuery(“#custom-email-input”).val()) != ”) { var sCustomemails = jQuery(“#custom-email-input”).val().split(‘,’); jQuery.each(sCustomemails, function(index, email) { if(!validEmail(email)) { jQuery(“#custom-email-input”).addClass(‘error’); alert(‘Please enter only valid email addresses.’); jQuery(“#custom-email-input”).attr(‘placeholder’,’Please enter only valid email addresses’); error=true; } else { jQuery(“#id_subject”).removeClass(‘error’); } }); }
How to explode a string to an array in javascript or jQuery
Using javascript or jQuery function split() for explode string to array Example: if(jQuery.trim(jQuery(“#custom-email-input”).val()) != ”) { var sCustomemails = jQuery(“#custom-email-input”).val().split(‘,’); alert(sCustomemails ); }
Kill a jQuery function using unbind()
Using The following jquery function to kill a function(unbind/bind) Syntax: jQuery(this).unbind(‘<function name>’); Example: jQuery(“#message_send”).live(“click”, function(){ jQuery(this).unbind(‘autosave’); });