<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'jQuery snippet to convert numbers into US phone number format as they're typed'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Sun, 19 May 2013 10:09:32 GMT</pubDate>
<item>
<title>bas3pix said on 11/17/12</title>
<link>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</link>
<description><![CDATA[ Hi guys, maybe this script can help further improve your script:
http://www.deltadeveloper.nl/fragmenten/telephone-number-formatting-script. It really helped us in formatting telephone numbers. Hopelfully it can be of great use for your guys or any of your visitors. ]]></description>
<pubDate>Sat, 17 Nov 2012 07:37:14 GMT</pubDate>
<guid>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</guid>
</item>
<item>
<title>jcc2010 said on 12/20/11</title>
<link>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</link>
<description><![CDATA[ Just a little improvement, take it if you like:

HTML5 has the input type=tel form element now, so you can do something like this:

	$("input[type='tel']").keyup(function() {
		var curchr = this.value.length;
		var curval = $(this).val();
		if (curchr == 3) {
			$(this).val("(" + curval + ")" + "-");
		} else if (curchr == 9) {
			$(this).val(curval + "-");
		}
	});

Using the $(this) keeps it from changing other inputs on the page. ]]></description>
<pubDate>Tue, 20 Dec 2011 23:17:10 GMT</pubDate>
<guid>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</guid>
</item>
<item>
<title>rewdy said on 2/11/11</title>
<link>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</link>
<description><![CDATA[ i am fail. :( ]]></description>
<pubDate>Fri, 11 Feb 2011 03:04:38 GMT</pubDate>
<guid>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</guid>
</item>
<item>
<title>rewdy said on 2/11/11</title>
<link>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</link>
<description><![CDATA[ ...between the <script%gt;</script%gt; tags... ]]></description>
<pubDate>Fri, 11 Feb 2011 03:03:24 GMT</pubDate>
<guid>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</guid>
</item>
<item>
<title>rewdy said on 2/11/11</title>
<link>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</link>
<description><![CDATA[ ha ha.. this is javascript&amp;mdash;not php. It goes between  tags in the head of your HTML document. ]]></description>
<pubDate>Fri, 11 Feb 2011 03:02:14 GMT</pubDate>
<guid>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</guid>
</item>
<item>
<title>gvisitac said on 1/17/10</title>
<link>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</link>
<description><![CDATA[ Hello,  I am trying to use your code for my test form and I can't get it to work.  Can you please tell me where this code should be in my .php file.  

I've tried before this line: 

I've tried before the 

and I've tried inside the form tags without any success to get it to work.

Can you please suggest where, exactly, this should be?


Here's my code for a test form:



$(function() {
	$("input[@name='phone']").keyup(function() {
		var curchr = this.value.length;
		var curval = $(this).val();
		if (curchr == 3) {
			$("input[@name='phone']").val("(" + curval + ")" + "-");
		} else if (curchr == 9) {
			$("input[@name='phone']").val(curval + "-");
		}
	});
});






Untitled Document



  
  
  
  <p>
    
    
    
  </p> ]]></description>
<pubDate>Sun, 17 Jan 2010 20:53:19 GMT</pubDate>
<guid>http://snipplr.com/view/11578/jquery-snippet-to-convert-numbers-into-us-phone-number-format-as-theyre-typed/</guid>
</item>
</channel>
</rss>