JS Form Validation
<pre><code>&lt;html&gt; 
&lt;head&gt; 
&lt;title&gt;Coupon test code&lt;/title&gt; 
&lt;style&gt;
#error{
color: red;
font-weight: bold;
}
&lt;/style&gt;
&lt;/head&gt; 

&lt;body&gt; 
    &lt;form name="couponField" action=""&gt; 
        &lt;span id="error"&gt;&lt;/span&gt;
        Coupon code: 
        &lt;input type="coupon" id="coupon" name="coupon"&gt; 
        &lt;input type="button" id="submit" value="Apply Coupon Code"&gt; 
    &lt;/form&gt; 

&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
$('#submit').click(function(){
    if($('#coupon').val() == 'PROMO CODE'){
        $('#error').text('correct code!');
    }else{
        $('#error').text('wrong code!');
    }

});
&lt;/script&gt;

&lt;/body&gt; 
&lt;/html&gt;
</code></pre>

<p>The above code does the following:
1. Validate if the coupon code entered is exactly equal to 'PROMO CODE'
2. Validate if the field is empty. </p>

<p>What we are trying to do:
1. Keep the validation for 'PROMO CODE' intact.
2. Remove the validation for the empty field.</p>

<p>This is a part of an order form wherein we want the users to enter the promo code. But since all the users may not have the promo code we want to give the users the option to leave the field empty. The current validation is making this field a 'required' field. </p>

<p>Any suggestions are much appreciated. Thanks!</p>
