Hobbyist_PHPer Posted May 30, 2012 Share Posted May 30, 2012 Hi, I had, had a payment form script written for me, but since then I've had to make changes to it, specifically, making it dynamic... The old version of the script/form had a static set price and connection fee, I've since changed that... but one thing that never has worked, that I really need to get working is, if there is a minimum amount of minutes that a client must enter before the jQuery script calculates and populates the total... Here's what I have so far... (Note: This script works with 2 input boxes, one is "amtmin", which stands for "Amount of Minutes" and the other input box is, "totcost", which stands for "Total Cost" ... As you can see, I have PHP setting the values of the jQuery variables. ... So the question is, what I need help with, is when a purchasing client enters the amount of minutes in the "amtmin" input box and then leaves the input box, .blur() (I think), then I need the script to ensure that the minimum amount of minutes has been entered, if not, return the purchasing client back to the "amtmin" input box, with .focus() (I think) <script type="text/javascript"> jQuery(document).ready(function() { jQuery("#contact").mask("(999) 999-9999"); jQuery("#amtmin").mask("9?99999999999",{placeholder:" "}); jQuery("#cvvcode").mask("999",{placeholder:" "}); }); </script> <script type="text/javascript"> var minimumMinutePurchase = <? echo $MinuteMinimumPurchase; ?>; var pricePerMinute = <? echo $PayPerMinuteRate; ?>; var connectionFee = <? echo $PayPerMinuteConnectionFee; ?>; jQuery(function() { jQuery("#amtmin").change(function() { jQuery("#amtmin").val(jQuery("#amtmin").val()==""?"0":jQuery("#amtmin").val());// handling an empty value if(jQuery("#amtmin").val()!="0") jQuery("#totcost").val((parseInt(jQuery("#amtmin").val())*pricePerMinute+connectionFee).toFixed(2)); else jQuery("#totcost").val(0); }); }); </script> Quote Link to comment https://forums.phpfreaks.com/topic/263404-jquery-blur-help/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.