Permalink
Browse files

Mask: fix isValid logic; previously, any call to getValue(true) resul…

…ted in isValid being set to true
  • Loading branch information...
1 parent 26c1864 commit 74f44396b5a5f37fee8c77532cd05f33399c5546 Zach Shepherd committed Oct 15, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 ui/jquery.ui.mask.js
View
@@ -124,8 +124,8 @@ $.widget( "ui.mask", {
this.isEmpty = this.isValid = true;
for ( bufferPosition = 0; bufferPosition < bufferLength; bufferPosition += bufferObject.length ) {
bufferObject = this.buffer[ bufferPosition ];
- if ( bufferObject.literal && !raw ) {
- if ( bufferPosition < this.optionalPosition || this.isValid ) {
+ if ( bufferObject.literal ) {
+ if ( !raw && bufferPosition < this.optionalPosition || this.isValid ) {
value += bufferObject.literal;
}
} else if ( bufferObject.value ) {
@@ -135,9 +135,11 @@ $.widget( "ui.mask", {
for ( counter = bufferObject.value.length; counter < bufferObject.length; counter++ ) {
value += this.options.placeholder;
}
- } else if ( !raw ) {
- for ( counter = bufferObject.length ; counter; counter-- ) {
- value += this.options.placeholder;
+ } else {
+ if ( !raw ) {
+ for ( counter = bufferObject.length ; counter; counter-- ) {
+ value += this.options.placeholder;
+ }
}
if ( bufferPosition < this.optionalPosition ) {
this.isValid = false;

0 comments on commit 74f4439

Please sign in to comment.