Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.