Jump to content

jQuery .blur() Help


Hobbyist_PHPer

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/263404-jquery-blur-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.