Forums

validation for dollar amt

md520 23 Jun, 2009
Hello,

I've created a form using Chronoforms specifically to take advantage of the validation features. Everything is working great and I'm thrilled with this component, however would like to validate a field called "charge_total" to require the dollar format of 0.00 (no $, and two decimal places).

This form posts to a 3rd party hosted pay configuration for credit card processing, and the provider requires the charge_total field be in the 0.00 format in order for the transaction to complete.

help is much appreciated, my javascript coding is minimal.
m
Max_admin 23 Jun, 2009
hi md520,

then this should be done using a custom rule, make sure you know the field_id and use this code in the JS code box


            window.addEvent('domready', function() {
            var amount = new LiveValidation('amount');
            amount.add( Validate.Format, { pattern: /^[0-9]\.[0-9][0-9]+$/i } );
            });
//I assumed that the field id is amount


you will probably need to use a similar rule in the Server side validation box to securely stop anyway to pass any other value!

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
md520 24 Jun, 2009
Thanks for the quick reply. I inserted the code into the js box, changing the field value from amount to charge_total, which is the proper field, however I cannot get it work - do I need to add any additional brackets/code?

The following code is also in the javascript box, <SRC="//smarticon.geotrust.com/si.js"> but even if I remove it I cannot get the validation to work.

Also, you mentioned I'll need something "similar" in the server side scripting box, however I am not trained in any server side scripting- can I copy and paste the same code in there, or does it need to be something different?

Thanks again for the great component and support.
Max_admin 24 Jun, 2009
Hi, lets get the JS code working first, show me what you have in the JS box and show me the field HTML code and tell me which Chronoforms version do you have ?

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
md520 24 Jun, 2009
Thanks. Here is what is in the javascript box:
window.addEvent('domready', function() {
            var amount = new LiveValidation('charge_total');
            charge_total.add( Validate.Format, { pattern: /^[0-9]\.[0-9][0-9]+$/i } );
            });

<SRC="//smarticon.geotrust.com/si.js">


html for that field:
<tr>
<td><input name="charge_total" size="10" type="text" /></td>
</tr>


I also have validation set in the validation tab for "10-dollar amount" for charge_total.

CHronoforms is version 3.1 RC5.1 and I purchased a license.
Max_admin 25 Jun, 2009
ok, remove the charge_total from the validation field and make your code like this:

    window.addEvent('domready', function() {
                var charge_total = new LiveValidation('charge_total');
                charge_total.add( Validate.Format, { pattern: /^[0-9]\.[0-9][0-9]+$/i } );
                });

    <SRC="//smarticon.geotrust.com/si.js">



Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
md520 25 Jun, 2009
ah - sorry for wasting your time with that one - I can't believe I missed that var amount replacement.

Nevertheless it is still not working, can I pm you the full code and site access?

thanks
Max_admin 26 Jun, 2009
well, try to remove the last line with SRC then, I'm not sure if this is correct one!

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
md520 26 Jun, 2009
still no luck, with the SRC line of code removed. When I press the submit button, with a value fo "5" in the charge_total field, it progresses to the 3rd party hosted paypage.....I assume that when the validation is working properly it will not allow me to go to that page until the number reads 5.00. All the other validations work great.

Any other ideas? I appreciate the help and will be voting for your component on joomla extensions once I have this figured and some more time.
Max_admin 26 Jun, 2009
your field tag doesn't have an id attribute, please add it and it will work fine, just tested it here!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
md520 27 Jun, 2009
I don't doubt this is me doing something stupid, or missing something small....nevertheless, here's the code from the form for that field where I added the ID....still no luck though. The URL is http://www.rotaplastcanada.com and you can access the form by clicking on "donate now".

<tr>
<td><input name="charge_total" size="10" type="text" id="charge_total"/></td>
</tr>


thanks
Max_admin 28 Jun, 2009
hmm, I see, please get the RC5.2 which I will release in the next few hours and retest using it, the upgrade is very easy

Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.