Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/demo-as-you-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<link rel="stylesheet" href="http://www.teamdf.com/jquery-plugins/resources/stylesheets/prettify.css"/>
<link rel="stylesheet" href="http://www.teamdf.com/jquery-plugins/resources/stylesheets/docs.css"/>

<script type="text/javascript">

$(function(){
Expand All @@ -28,7 +28,7 @@
console.log('Second change event...');
});

$('#price').number( true, 2 );
$('#price').number( true, 2, ",", "." );


// Get the value of the number for the demo.
Expand All @@ -40,7 +40,7 @@
});
});
</script>

<link rel="stylesheet" href="http://www.teamdf.com/jquery-plugins/resources/stylesheets/prettify.css" type="text/css" />

<style>
Expand Down
9 changes: 7 additions & 2 deletions jquery.number.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
*/
var _keydown = {
codes : {
110 : 44,
46 : 127,
188 : 44,
109 : 45,
Expand All @@ -99,7 +100,6 @@
187 : 61, //IE Key codes
186 : 59, //IE Key codes
189 : 45, //IE Key codes
110 : 46 //IE Key codes
},
shifts : {
96 : "~",
Expand Down Expand Up @@ -145,6 +145,9 @@
regex_dec_num = new RegExp('[^'+u_dec+'0-9]','g'),
regex_dec = new RegExp(u_dec,'g');

var u_tho = ('\\u'+('0000'+(thousands_sep.charCodeAt(0).toString(16))).slice(-4)),
regex_tho = new RegExp(u_tho,'g');

// If we've specified to take the number from the target element,
// we loop over the collection, and get the number.
if( number === true )
Expand Down Expand Up @@ -345,6 +348,7 @@
if( this.value.slice(start, start+1) != '0' )
{
val = this.value.slice(0, start) + '0' + this.value.slice(start+1);
val = val.replace(regex_tho,'');
// The regex replacement below removes negative sign from numbers...
// not sure why they're necessary here when none of the other cases use them
//$this.val(val.replace(regex_dec_num,'').replace(regex_dec,dec_point));
Expand All @@ -369,6 +373,7 @@
if( this.value.slice(start-1, start) != '0' )
{
val = this.value.slice(0, start-1) + '0' + this.value.slice(start);
val = val.replace(regex_tho,'');
// The regex replacement below removes negative sign from numbers...
// not sure why they're necessary here when none of the other cases use them
//$this.val(val.replace(regex_dec_num,'').replace(regex_dec,dec_point));
Expand Down Expand Up @@ -432,7 +437,7 @@
// If we need to re-position the characters.
if( setPos !== false )
{
//console.log('Setpos keydown: ', setPos );
//console.log('Setpos keydown: ', setPos );
setSelectionRange.apply(this, [setPos, setPos]);
}

Expand Down
3 changes: 1 addition & 2 deletions jquery.number.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.