Answer the question
In order to leave comments, you need to log in
How to change the condition so that the button would be lit not with one character, but with a certain number?
Here is a code example:
$(function(){
var inputs = $('[data-mask]');
if( inputs.length == 0 ) return false;
inputs.filter(':not(.ready)').each(function(){
var inp = $(this);
var mask = inp.attr('data-mask');
inp.mask( mask,{placeholder:"_"} ).addClass('ready');
});
$(document)
.delegate('.js-numeric','keypress',function(e){
var key = e.which;
if( key !=8 && key !=0 && ( key < 48 || key > 57 ) ) return false;
})
.delegate('[required]','keyup change', function(e){
var group = $(this).parents('.form-group');
group.find('.error-block').slideUp('fast',function(){ group.removeClass('error'); });
required();
})
.delegate('[data-mask]','blur',function(){
required();
});
// check required fields
var required = function(){
$('form').each(function(){
var form = $(this);
var enable = true;
form
.find('[required]')
.filter('input[type="hidden"], input[type="text"], input[type="password"], input[type="email"], textarea, select')
.each(function(){
if( !$(this).val() ) enable = false;
}).end().end()
.find('button,input[type="button"]').filter('[required]').attr('disabled', ( enable ? false : true ) );
});
};
});
Answer the question
In order to leave comments, you need to log in
jsfiddle.net/0xL0fctq/3
only if this is not the only field in the form, then you need to check that this is it, for example like this:
if( !$(this).val() || (
$(this).attr('name') == 'phone'
&& $(this).val().replace(/\D/g,'').length < 5
)) enable = false;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question