programer.tips, another cool thing from @nghuuphuoc!

Playing with Mask

Examples

Improve it on Github

Use with the Mask plugin.

<!-- Include Mask plugin -->
<script src="//oss.maxcdn.com/jquery.mask/1.6.0/jquery.mask.min.js"></script>

<form id="maskForm" method="post" class="form-horizontal">
    <div class="form-group">
        <label class="col-sm-3 control-label">IP address</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="ipAddress" />
        </div>
    </div>
</form>
$(document).ready(function() {
    $('#maskForm')
        .bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                ipAddress: {
                    validators: {
                        ip: {
                            message: 'The IP address is not valid'
                        }
                    }
                }
            }
        })
        .find('[name="ipAddress"]').mask('099.099.099.099');
});