javascript - Check if all input field lengths are 7 -


there multiple input fields common class. need check if length of fields 7.

this tried, if length of fields 7, if (!lengthcheck) doesn't execute.

var lengthcheck = $('.price').filter(function(){       return !$.trim($(this).val()).length != 7; }).length;  if(!lengthcheck){  //go ahead } 

your issue because logic check reversed. need remove leading !:

return $.trim($(this).val()).length != 7; 

working example


Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

angular - Angular2 Router: Cannot find primary outlet to load 'HomeComponent' -

qt - Microsoft FTP Service 451 The parameter is incorrect -