Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Mask: playing with the handling of the multi character fields

  • Loading branch information...
commit b21fc2f09fcad5c8cdcd1cf17eca8fef44f2dc7f 1 parent 926c08a
@gnarf gnarf authored
Showing with 11 additions and 3 deletions.
  1. +11 −3 ui/jquery.ui.mask.js
View
14 ui/jquery.ui.mask.js
@@ -206,9 +206,13 @@ $.widget( "ui.mask", {
if ( bufferObject && bufferObject.length > 1 ) {
bufferObject.value = this._validValue( bufferObject, bufferObject.value );
that._paint();
- that._caret( that._seekRight( bufferObject.start + bufferObject.length - 1 ) );
event.preventDefault();
-
+ }
+ position = that._seekRight( bufferObject.start + bufferObject.length - 1 );
+ bufferObject = that.buffer[ position ];
+ if ( bufferObject && bufferObject.length > 1 ) {
+ that._caret( position, position + ( bufferObject && bufferObject.length > 1 ? bufferObject.length : 0 ) );
+ event.preventDefault();
}
}
return;
@@ -398,7 +402,9 @@ $.widget( "ui.mask", {
destPosition += destObject.length ) {
destObject = this.buffer[ destPosition ];
bufferObject = this.buffer[ bufferPosition ];
- if ( destObject.valid ) {
+
+ // we don't want to shift values into multi character fields
+ if ( destObject.valid && destObject.length === 1 ) {
if ( bufferPosition < bufferLength ) {
if ( this._validValue( destObject, bufferObject.value ) ) {
destObject.value = bufferObject.value;
@@ -426,6 +432,8 @@ $.widget( "ui.mask", {
if ( shiftingValue === false ) {
shiftingValue = bufferObject.value;
} else {
+
+ // we don't want to shift values into multi character fields
if ( bufferObject.length === 1 && this._validValue( bufferObject, shiftingValue ) ) {
temp = bufferObject.value;
bufferObject.value = shiftingValue;
Please sign in to comment.
Something went wrong with that request. Please try again.