• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Forms / dFilter

dFilter

dFilter

This script will easily allow you to add an input mask to a textbox. The mask for a phone number could look like this for example “(###) ###-####”. Just give it a try to see it in action!

  1. Download the external JavaScript file
  2. Copy the coding into the HEAD of your HTML document
  3. Add the last code into the BODY of your HTML document
<!– STEP ONE: Download the external JavaScript file here:  –>

       http://javascriptsource.com/forms/dFilter.js


<!– STEP TWO: Paste this code into the HEAD of your HTML document  –>

<HEAD>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascriptsource.com –>

<script type=’text/javascript’ src=’dFilter.js’></script>
</script>

</HEAD>

<!– STEP TWO: Copy this code into the BODY of your HTML document  –>

<BODY>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascriptsource.com –>

<form name=”fred” action=”fred.htm” method=”post”>
<table>
    <tr>
		    <td>SSN:</td>
				<td><input value=”” type=”text” onKeyDown=”javascript:return dFilter (event.keyCode, this, ‘###-##-####’);” style=”font-family:verdana;font-size:10pt;width:110px;”></td>
		</tr>
    <tr>
        <td>Phone:</td>
				<td><input value=”” type=”text” onKeyDown=”javascript:return dFilter (event.keyCode, this, ‘(###) ###-####’);” style=”font-family:verdana;font-size:10pt;width:110px;”></td>
		</tr>
		<tr>
        <td>Zip:</td>
				<td><input value=”” type=”text” onKeyDown=”javascript:return dFilter (event.keyCode, this, ‘#####-####’);” style=”font-family:verdana;font-size:10pt;width:110px;”></td>
		</tr>
</table>
</form>

<p><center>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”https://javascriptsource.com”>The JavaScript Source</a></font>
</center><p>

Forms

Related Snippets:

  • 3 Ways To Get The Selected Value in a Dropdown List Using JavaScript
  • Preventing paste into an input field
  • Validate Numeric Only
  • onMouseOver Button

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers