Skip to content

Commit b21fc2f

Browse files
committed
Mask: playing with the handling of the multi character fields
1 parent 926c08a commit b21fc2f

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ui/jquery.ui.mask.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,13 @@ $.widget( "ui.mask", {
206206
if ( bufferObject && bufferObject.length > 1 ) {
207207
bufferObject.value = this._validValue( bufferObject, bufferObject.value );
208208
that._paint();
209-
that._caret( that._seekRight( bufferObject.start + bufferObject.length - 1 ) );
210209
event.preventDefault();
211-
210+
}
211+
position = that._seekRight( bufferObject.start + bufferObject.length - 1 );
212+
bufferObject = that.buffer[ position ];
213+
if ( bufferObject && bufferObject.length > 1 ) {
214+
that._caret( position, position + ( bufferObject && bufferObject.length > 1 ? bufferObject.length : 0 ) );
215+
event.preventDefault();
212216
}
213217
}
214218
return;
@@ -398,7 +402,9 @@ $.widget( "ui.mask", {
398402
destPosition += destObject.length ) {
399403
destObject = this.buffer[ destPosition ];
400404
bufferObject = this.buffer[ bufferPosition ];
401-
if ( destObject.valid ) {
405+
406+
// we don't want to shift values into multi character fields
407+
if ( destObject.valid && destObject.length === 1 ) {
402408
if ( bufferPosition < bufferLength ) {
403409
if ( this._validValue( destObject, bufferObject.value ) ) {
404410
destObject.value = bufferObject.value;
@@ -426,6 +432,8 @@ $.widget( "ui.mask", {
426432
if ( shiftingValue === false ) {
427433
shiftingValue = bufferObject.value;
428434
} else {
435+
436+
// we don't want to shift values into multi character fields
429437
if ( bufferObject.length === 1 && this._validValue( bufferObject, shiftingValue ) ) {
430438
temp = bufferObject.value;
431439
bufferObject.value = shiftingValue;

0 commit comments

Comments
 (0)