Category Archives

Archive of posts published in the category: Jquery
Mar
20

Email Id validation in jquery

<script src=”https://code.jquery.com/jquery-1.11.3.js”></script> <script > function ValidateEmail(emailId) { var expr = /^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/; return expr.test(emailId); }; $(document).ready(function(){ $(“#submit “).click(function(){ var email = $(“#email”).val(); if(email == ”){ alert(“Please enter Email Id”); } else if (!ValidateEmail(email)) { alert(“Invalid email address”); } else { alert(“Valid Email id”); }…

Sep
7

Change background color in jquery onclick

// add js library <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script> <script> function changeBg(){ $(“body”).css(“background-color”,”blue”); } </script> <body> <div onclick=”changeBg()”>Click</div> </body> </html>

Nov
15

Find difference between two numeric values

<script> var x = 12; var y = 15; var z = Math.abs(x-y); alert(z); </script>  

Nov
12

How to check for an undefined in jquery

<script> if(typeof(a) == “undefined”){ alert(‘undefined valiable’); } else { alert(‘OK’); } </script>

Oct
16

Check Value numeric or not?

Check value is numeric or not in jquery:

Oct
2

Create jQuery plugin

// function definition

(function ( $ ) {

$.fn.greenify = function() {
this.css( “color”, “green” );
return this;
};

}( jQuery ));

//function calling

$( “a” ).greenify();

Sep
30

Open url in new tab in jquery

window.open(“your url”, ‘_blank’);

Sep
22

Get page url in jquery

Paste this code in html body: <a href=”#detail” onclick=”CallUrl();”>Click to get url</a> Now start scripting 1. Add jquery library file <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script> 2. paste the following code in script tag as below: <script> // function definition function CallUrl(){ var pageURL = $(location).attr(“href”); alert(pageURL);…