$(this).attr('id') == 'zipcode' && $this.value()!=(3, 4, 5)
What I tried to do here was call up the text input field with an id of "zipcode" and say something along the lines of "if value of zipcode is not 3, 4, or 5 then... etc etc..." I tried many combinations including || but nothing has worked. I'll be listing all the possible zip codes and would require the shortest possible way to do it.
Much appreciated.
Full code:
function validateStep(step){ if(step == fieldsetCount) return;
var error = 1;
var hasError = false;
$('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input.req:not(button)').each(function(){
var $this = $(this);
var valueLength = jQuery.trim($this.val()).length;
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
if(valueLength == "" || $(this).attr('id') =='email' && !emailPattern.test($this.val()) || $(this).attr('id') == 'zipcode' && $this.value()!=(3, 4, 5))
{
hasError = true;
$this.css('background-color','#FFEDEF');
}
else
$this.css('background-color','#fff');
});