I have a quick question and I feel like I might just be missing something easy.
I currently have an array of codes below the document ready function of my jquery
$(document).ready(function() {
var code = ['code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'code', 'HG3BV', 'code', 'code', 'code', 'code', 'code', 'code'];
"use strict";
This is at the top of my js document.
Then down further I check on my forms if it finds a class value of validate-required2 and if it does, I want it to check the value of the textbox #codes against my array.
$(form).find('.validate-required2').each(function() {
var cheater = $('#codes').val();
if (jQuery.inArray(cheater, code)!='-1') {
$(this).removeClass('field-error');
} else {
$(this).addClass('field-error');
error = 1;
}
});
However this is constantly returning that the values aren't in the array. Did I miss something easy here?
codearray declaration outside$(document).ready, before it.