Skip to content

Instantly share code, notes, and snippets.

@g5codyswartz
Created May 29, 2015 17:54
Show Gist options
  • Save g5codyswartz/766bec2a3fb4abd81b5b to your computer and use it in GitHub Desktop.
Save g5codyswartz/766bec2a3fb4abd81b5b to your computer and use it in GitHub Desktop.
Add Location Input Length Checker
var longInputTextLengths = 0;
var inputTextFields = $('input[type=text]');
var inputTextFieldsCount = inputTextFields.length;
$(inputTextFields).each(function() {
if($(this).val().length > 155) {
console.log(this);
console.log('^ Above element character length: '+$(this).val().length);
longInputTextLengths++;
}
inputTextFieldsCount--; // count down our elements we're iterating through
// Check for last loop and if we found any inputs over our threshold
if (inputTextFieldsCount === 0 && longInputTextLengths > 0)
alert('Found '+longInputTextLengths+' text inputs that were over 155 characters in length. Check the Console for more information.');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment