decimal comparision javascript | |
---|---|
Subject: | |
var price = $( 'input[name="product-price"]' ).val(); var discount = $( this ).val();
if( $( this ).val() ){ //get price and make sure its bigger than discount if( parseFloat(price) == parseFloat(discount) ){ alert('<?php echo __('please note your discount will provide this as a free product') ?>'); }
if( parseFloat(price) < parseFloat(discount) ){ var placeholder = $( this ).val(); alert('<?php echo __('the discount cannot be higher than the price') ?>'); //$( this ).val('').attr('placeholder', placeholder); $( this ).closest('.input-group').addClass('has-error'); //$( this ).focus(); } } | |
2017-07-25 15:35:23 | gstlouis |