jeudi 5 avril 2018

Checking multiple condition values does not output the else statement

I am attempting to check a list of zip codes and then assign the variable zipAssign a value based on if the zip code entered matches one from the list.

In the codes current state it always displays "AB".

Does anyone see what I am doing wrong?

$('#salesforce_submit').change(function () {
                //Find AB Zip Code
                var zipVal = '';
                var zipAssign = '';
                zipVal = $('#zip').val();
                if (zipVal = 44030 || 44048 || 44082 || 44003 || 44093 || 44076 || 44062 || 44021 || 44046 || 44099 || 44032 || 44047 || 44010 || 44057 || 44086 || 44064 || 44024 || 44023 || 44065 || 44022 || 44072 || 44040 || 44143 || 44094 || 44139 || 44146 || 44128 || 44105 || 44122 || 44124 || 44121 || 44117 || 44108 || 44110 || 44103 || 44106 || 44118 || 44120 || 44104 || 44114 || 44127 || 44125 || 44131 || 44134 || 44129 || 44130 || 44144 || 44109 || 44115 || 44136 || 44133 || 44147 || 44141 || 44067 || 44056 || 44087 || 44195) {   
                        zipAssign = 'AB';
                } else {
                        zipAssign = '';
                }
                console.log(zipAssign);
        });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form id="salesforce_submit" method="POST" enctype="multipart/form-data">
                <div><input id="zip" placeholder="Zip/Postal Code*" class="input block" maxlength="6" name="zip" type="text" pattern= "[0-9]{5}"></div>
    <input type="submit">
</form>

Aucun commentaire:

Enregistrer un commentaire