Jquery- Check if is valid price or not

Check the valid price in Jquery. If the price is valid or not.It returns TRUE or FALSE.


function CheckValidPrice(price=0){
 var tempPrice = Math.round(price * 100)/ 100;
 var RE = /^(?!^0*$)(?!^0*\.0*$)^\d{1,7}(\.\d{1,2})?$/;
 if(RE.test(tempPrice)){
 return true;
 }else{
 return false;
 }
 }
Please follow and like us:
0