'jquery masked input plugin to not clear field?

In my project I'm using these following plugins for validation

     jquery.validate.min.js, 
     jquery.ui.core.js,
     jquery.ui.widget.js, 
     jquery.ui.mask.js

I'm calling it like this:

     $('#txtShippingInfoPhone').mask({mask:"999-999-9999",clearEmpty: false});

By default input box is empty. like this

  Phone number: 

when i keyup on that textbox its look like this

Phone number:___ ___ ____

And, If I enter wrong phone number then it is accepting. e.g:

 [407-555-____]

But here, error should through instead of accept the value. Observation: Its consider __ __ ____ also value.



Solution 1:[1]

I don't know how you validate the form, but if is the default proceedment, you are only checking if the field is not empty (required).

You need to check if the phone value match the mask before... and then continue with the validation.

Example

if($('#txtShippingInfoPhone').mask("valid")){
    /* It's valid, continue with the submit... */
    return true;
}else{
    /* It's NOT valid, trigger the error msg, and interrupt the submit... */
    return false;
}?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gmo