logo
  • Home
  • About
  • Services
  • Portfolio
  • Contact Us
  • Submit Guest post
How To Mask Input Using CSS And Jquery

How To Mask Input Using CSS And Jquery

December 2, 2016 No comments Article SEO Website Designing

How To Mask Input Using CSS And Jquery: Hi friends, today I will tell you about input masking with css and jquery. Generally you have seen the credit card, phone number, fax, zip code input boxes in which some text is written like extension of phone number or some code.

You can also write some characters in the input field to help the user, you have seen the coupan code of some website in which some characters have written already.

How To Mask Input Using CSS And Jquery Live Demo:

You can see the live demo of sliding div and download the code from below

SEO Website Designing Live Demo      SEO Website Designing Download

Some Example of Input Masking are:

Phone Number

(0124)-999-9999

Mobile Number

(+91)-99999-99999

Birth Date

21/11/1992

Date

21/11/2016

Time

10:01:54

Zip Code

123456

Credit Card

1234/5678/9101/1123

Tax ID

01-2345678

SSN

999-99-99999

Coupan Code

ABCD-8989-7878-2323



How To Mask Input Using CSS And Jquery

For Masking any input field for giving the user clear picture of date, phone, credit card format. You have to click on the input field and you can see the format. To do input masking you can paste some code in the webpage. These code are

Bootstrap HTML Code:

I have made some of the useful input field using bootstrap. some of the fields are phone number, mobile, tax id, ssn etc.

<div class="row form-horizontal">
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="phone">Phone Number:</label>
         <input class="col-lg-6" type="text" class="form-control" id="phone">
         <label class="col-lg-3" for="phone">(0124)-999-9999</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="mobile">Mobile Number:</label>
         <input class="col-lg-6" type="text" class="form-control" id="mobile">
         <label class="col-lg-3" for="mobile">(+91)-99999-99999</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="bd">Birth Date:</label>
         <input class="col-lg-6" type="text" class="form-control" id="bd">
         <label class="col-lg-3" for="bd">21/11/1992</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="date">Date:</label>
         <input class="col-lg-6" type="text" class="form-control" id="date">
         <label class="col-lg-3" for="date">21/11/2016</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="time">Time:</label>
         <input class="col-lg-6" type="text" class="form-control" id="time">
         <label class="col-lg-3" for="time">10:01:54</label>
      </div>
   </div>
</div>
<div class="row form-horizontal">
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="zip">Zip Code:</label>
         <input class="col-lg-6" type="text" class="form-control" id="zip">
         <label class="col-lg-3" for="zip">123-456</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="credit">Credit Card:</label>
         <input class="col-lg-6" type="text" class="form-control" id="credit" data-inputmask="'mask': '9999 9999 9999 9999'">
         <label class="col-lg-3" for="credit">1234/5678/9101/1123</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="tax">Tax ID:</label>
         <input class="col-lg-6" type="text" class="form-control" id="tax">
         <label class="col-lg-3" for="tax">01-2345678</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="ssn">SSN:</label>
         <input class="col-lg-6" type="text" class="form-control" id="ssn">
         <label class="col-lg-3" for="ssn">999-99-99999</label>
      </div>
   </div>
   <div class="col-md-12">
      <div class="form-group">
         <label class="col-lg-3 text-right" for="coupan">Coupan Code:</label>
         <input class="col-lg-6" type="text" class="form-control" id="coupan">
         <label class="col-lg-3" for="coupan">ABCD-8989-7878-2323</label>
      </div>
   </div>
</div>

<div class="row form-horizontal"> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="phone">Phone Number:</label> <input class="col-lg-6" type="text" class="form-control" id="phone"> <label class="col-lg-3" for="phone">(0124)-999-9999</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="mobile">Mobile Number:</label> <input class="col-lg-6" type="text" class="form-control" id="mobile"> <label class="col-lg-3" for="mobile">(+91)-99999-99999</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="bd">Birth Date:</label> <input class="col-lg-6" type="text" class="form-control" id="bd"> <label class="col-lg-3" for="bd">21/11/1992</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="date">Date:</label> <input class="col-lg-6" type="text" class="form-control" id="date"> <label class="col-lg-3" for="date">21/11/2016</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="time">Time:</label> <input class="col-lg-6" type="text" class="form-control" id="time"> <label class="col-lg-3" for="time">10:01:54</label> </div> </div> </div> <div class="row form-horizontal"> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="zip">Zip Code:</label> <input class="col-lg-6" type="text" class="form-control" id="zip"> <label class="col-lg-3" for="zip">123-456</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="credit">Credit Card:</label> <input class="col-lg-6" type="text" class="form-control" id="credit" data-inputmask="'mask': '9999 9999 9999 9999'"> <label class="col-lg-3" for="credit">1234/5678/9101/1123</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="tax">Tax ID:</label> <input class="col-lg-6" type="text" class="form-control" id="tax"> <label class="col-lg-3" for="tax">01-2345678</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="ssn">SSN:</label> <input class="col-lg-6" type="text" class="form-control" id="ssn"> <label class="col-lg-3" for="ssn">999-99-99999</label> </div> </div> <div class="col-md-12"> <div class="form-group"> <label class="col-lg-3 text-right" for="coupan">Coupan Code:</label> <input class="col-lg-6" type="text" class="form-control" id="coupan"> <label class="col-lg-3" for="coupan">ABCD-8989-7878-2323</label> </div> </div> </div>


Jquery Code:

Jquery code is used to give them functionality for input masking. In the jquery code you define the format, you can define any special characters and for user input you have to write 9 (Nine).

In this i have used one input masking cdn of a plugin to make the .mask function work properly.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script>
      <script>
         $(document).ready(function(){
         $.mask.definitions['~']='[+-]';
             $("#phone").mask("(9999) 9999-999");
            $("#mobile").mask("(+99)-99999-99999");
            $("#bd").mask("99/99/9999");
            $("#date").mask("99/99/9999");
            $("#time").mask("99:99:99");
            $("#zip").mask("999-999");
            $("#credit").mask("9999/9999/9999/9999");
            $("#tax").mask("99-9999999");
            $("#ssn").mask("999-99-99999");
            $("#coupan").mask("ABCD-9999-9999-9999");
         });
      </script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script> <script> $(document).ready(function(){ $.mask.definitions['~']='[+-]'; $("#phone").mask("(9999) 9999-999"); $("#mobile").mask("(+99)-99999-99999"); $("#bd").mask("99/99/9999"); $("#date").mask("99/99/9999"); $("#time").mask("99:99:99"); $("#zip").mask("999-999"); $("#credit").mask("9999/9999/9999/9999"); $("#tax").mask("99-9999999"); $("#ssn").mask("999-99-99999"); $("#coupan").mask("ABCD-9999-9999-9999"); }); </script>

For any problem you can see the live demo and download the code from below.

SEO Website Designing Live Demo      SEO Website Designing Download

Now you know about How To Mask Input Using CSS And Jquery.

Read About Other Interesting Things about jquery below.

  • Sliding Div When Scroll Down Page Using Jquery
  • Disable Mouse Right Click Using Jquery
  • Responsive Jquery Read More Feature Without Plugin
  • Marquee Animation Without Marquee tag
  • Add 3D Menu Effects To Your Website Using Jquery
  • Rumbles, Vibrates, Shakes, And Rotates Any Element Using Jquery Plugin
  • Fancy Effects To Input Fields Using Jquery Plugin
  • Add Diwali Fireworks Using Jquery In Your Website
  • Zoom Image On Hover Using CSS Without Jquery
  • Pure HTML CSS Slider Without JavaScript or Jquery
  • Create Country State And City Dropdown Using Jquery
  • Learn JQUERY Code Step By Step For Beginners
  • Create Expand Collapse Sliding Menu Using jQuery
  • Jquery Me Simple Slider Kaise Bnate Hai
  • Add CKEditor in Html Form using Jquery
  • Avoid Spammers With Motion CAPTCHA Using JQuery
  • Stop Double Form Submission Using Jquery and Ajax
  • Simple Text Slider Using Jquery Slide Function

I hope you will like How To Mask Input Using CSS And Jquery. If You found it useful please subscribe my blog.

Share this:

  • Tweet
  • Telegram
  • WhatsApp
  • Share on Tumblr
  • Pocket
  • Email

Related

Categories: Website Design

Tags: Demo for css Masked Input, Demo for jQuery Masked Input, How To Mask Input Using CSS And Jquery, How to Mask Input with jQuery, HTML, html input mask, jquery, jquery masked input example

Leave a Reply Cancel reply

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,504 other subscribers

Categories

  • Angular (1)
  • Content Marketing (2)
  • Email Marketing (3)
  • Graphics Design (3)
  • Keyword Strategy (1)
  • Other (3)
  • Search Engine Optimization (10)
  • Social Media Optimization (4)
  • Website Design (67)
  • WordPress (18)
  • Subscribe to Blog via Email

    Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,504 other subscribers

  • Tag Cloud

    Add Social Share button in WordPress without Plugins Bootstrap center div on screen with flexbox center div vertically and horizontally in body center div vertically and horizontally responsive Center Elements Vertically And Horizontally Using Flex Centering in CSS Create Your Own Fast Social Sharing Buttons For WordPress Creating Scroll-based Animations using jQuery and CSS3 CSS CSS3 CSS3 Variables CSS custom properties CSS Variables custom share buttons wordpress Disable Mouse Right Click Using Jquery disable right click with jquery Disabling right mouse click menu facebook Get to Know the CSS Object Fit and Position Properties How Can You Use CSS Variables HOW TO CODE A RESPONSIVE EMAILER OR NEWSLETTER How to Create Social Sharing Button without any Plugin HOW TO DESIGN A RESPONSIVE EMAILER OR NEWSLETTER how to disable right click menu in html page How to prevent Right Click option using jquery How to Restore WordPress Website from Backup Manually How to use CSS Variables HTML HTML5 javascript jquery jQuery make div slide in when scrolling down page Know About CSS Object Fit and Position Properties Meta Tags Mysql object-fit object-fit/object-position object-position Responsive Website Sliding Div When Scroll Down Page Using Jquery Vertical Centering - Solved by Flexbox Webpage Scrolling Animation Effects with CSS3 & jQuery What You Need To Know About CSS Variables wordpress
  • Copyright SEO Website Designing 2015

    loading Cancel
    Post was not sent - check your email addresses!
    Email check failed, please try again
    Sorry, your blog cannot share posts by email.