Tag Archives: javascript

What is jQuery

Answers of the question “What is jQuery” is jQuery is a javascript library.

jQuery is written in javascript. It is a library to ease the use of javascript.

A rich library is developed to increase the usability of javascript in common and complex applications.

Javascript provides much functionality to manipulate the HTML DOM tree in the run.

Javascript is a lightweight script and so the jQuery. jQuery is based on javascript functionality.

jQuery simplifies the complex operations done in Javascript like AJAX, animation, DOM traversing and manipulation.

In the go, we can change, load and create HTML DOM and can do actions on them.

So jQuery is a powerful library. jQuery functionality provides a smoother User Experience.  It facilitates a handy tool to the programmers and designers.

The jQuery library has the following important features:

  • jQuery is an OPEN SOURCE
  • It can manipulate HTML/DOM similarly like javascript
  • We can add CSS and styles to HTML using jQuery functionality
  • jQuery handles the HTML event methods like click, hover, change, blur, etc
  • It is easy to manage Effects and animations when we are going with jQuery
  • It simplifies the AJAX request
  • jQuery has vast Utilities like jQuery Mobile, jQuery UI
  • A huge community is available over multiple networks
  • Compatible to almost the browsers

Few useful jQuery Functionality :

show(): display a hidden dom, set a style property display as Block.
hide(): Hide the selector from dom tree, visible on the browser.
animate(): Apply animation effects with selectors.
empty(): Empty the dom and also removes the child elements.
remove(): remove selector dom from tree
removeClass():remove class or classes from selectors
addClass():add class or classes to the selectors
toggleClass():add and remove simultaneously
stop(): stop the propagation of events
fadeIn():hide dom with a fading down effect.
fadeOut():display dom with a fading out effect.

Must Read: jQuery Functionality

Spread the love

Email Validation in Javascript

Email ID is a very important part of a user account. When an application invites the user to create accounts or allow users to subscribe to a newsletter, they ask for an email ID. Email ID is the initial medium of formal communication, so this is mandatory that the email is received should be in a valid format.

Here we are going to explain how to do Email Validation in JavaScript?

An Email is a string with a very simple structure. There are two parts :

  1. unique_id
  2. Domain Name

These two parts are separated by @. 

Suppose interviewsortout@gmail.com is an email where the first part interviewsortout is Unique User ID at the gamil.com domain.

The length of the unique_id part may be up to 64 characters long and domain name may be up to 253 characters.

The first part of an email may have the following characters :

  • May contain Alphabets either in upper case or in lower case.
  • Any Digits 
  • Special character except @  
  • a dot(.) can not be the first and last character of uique_id

The second part is the domain name. So we can have .com, .in, .info, .net, .au etc type of domain. 

Have a look at some valid email addresses:

  • info@interviewsortout.com
  • interviewsortout@gmail.com
  • sibbu2005@gmail.com
  • interview.sortout@gmail.com
  • userid@example.net
  • 23_user_23@example.in

 

Now Have a look on Invalid Email Address : 

  • @not present : [Example.user.com]
  • Top Level Domain can not be started with dot ( . ) : [user@.com.my ]
  • @user.example.net [ No character before @ ]
  •  invalid top level domain   [exampleuser123@gmail.b]
  • an email can not start with “.” [ .user@example.net ]
  • double dots are not allowed [interview..sortout@gmail.com]

 

To do email validation in javascript we will use Regular Expression to match that the given email address matches the criteria of a valid domain.

 

Regular Expression for email validation in JavaScript:

 

/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/

 

A complete Solution of Email Validation in Javascript :

Spread the love