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

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -