TOPIC:

Validating money amount with masked field 3 years 7 months ago #222289

  • Topic Author
  • SNuuDA
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 18
  • Thanks: 1
Hi,

I was now searching in the Forum and reading Documents, but I did not found the solution.
I have a textfield which I masked in the form:

echo '<script src="/d_web/Kunden/T2-Consulting/schwesternmaria/smaria38/includes/js/maskplugin/src/jquery.mask.js"
type="text/javascript"></script>';
echo '<script>
jQuery(function($){
$("#ff_elem301").mask("###.###.##0,00€", {reverse: true});
});
</script>';


This works fine.

I want to validate this field with a script.
I duplicated the script ff_dollaramount2dp and called it ff_euroamount2dp

I changed the code to:

function ff_euroamount2dp(element, message)
{
var ex = /^\d+$|^\d+\,\d{2}€/;
if (!ex.test(element.value)) {
if (message=='') message = element.name+" must be a number with two decimal places.\n";
ff_validationFocus(element.name);
return message;
} // if
return '';
} // ff_euroamount2dp


== > I changed the decimal point to comma and the $-sign to €-sign.

And this is also working fine.

Now the question:

How can I manange that the amount of EURO is minimum 5,00€?

Thank you very much in Advance.

Please Log in or Create an account to join the conversation.

Validating money amount with masked field 3 years 7 months ago #222290

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2222
  • Karma: 44
  • Thanks: 279
Hello,

please try out this code:
function ff_euroamount2dp(element, message)
{
var ex = /^\d+$|^\d+\,\d{2}€/;
var value = element.value;
var x = parseFloat(value.toString().split(",")[0]);
if (!ex.test(element.value)) {
if (message=='') message = element.name+" must be a number with two decimal places.\n";
ff_validationFocus(element.name);
return message;
}
else {
if (x < 5) {
if (message=='') message = element.name+" must be a value equal to or greater then 5,00€.\n";
ff_validationFocus(element.name);
return message;
}
}
return '';
}
Basically, the script will get the number before the comma and then it'll check if the number is lower than 5. If so, the validation error will come up. If the value is equal to or greater, the form will submit.
Try it out and let me know if it's working OK.

Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!

Please Log in or Create an account to join the conversation.

Last edit: Post by marko.bosnjak.

Validating money amount with masked field 3 years 7 months ago #222306

  • Topic Author
  • SNuuDA
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 18
  • Thanks: 1
Hi,
I say only WOW -It works .

Thank you very much, I coud not manage this alone.

How can I take the amount to a hidden field to transfer it later to PayPal.

The problem is: For example the Customer keys in:

600

This is converted to 6,00€
For PayPal I think I need 6.00 without the currency Symbol in a special field.

Thank you in advance.

Please Log in or Create an account to join the conversation.

Validating money amount with masked field 3 years 7 months ago #222336

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2222
  • Karma: 44
  • Thanks: 279
Hi gain,

you're welcome. :D

Here's what you need to do.
Go to your element that will take the price > Advanced tab > More options > Actionscript > Type > Custom > Actions > Change and paste this code in the framework:
function ff_NAME_OF_FIELD_action(element, action)
{
var val = element.value;
var price = val.replace(",",".");
var paypal_val = price.replace("€","");
ff_getElementByName('NAME_OF_HIDDEN_FIELD').value = paypal_val;
}
You'll have to insert the correct name of your field in the first line and the correct name of your hidden field in the last line.

Try it out and let me know the result.

Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!
The following user(s) said Thank You: SNuuDA

Please Log in or Create an account to join the conversation.

Validating money amount with masked field 3 years 7 months ago #222424

  • Topic Author
  • SNuuDA
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 18
  • Thanks: 1
Hi,

The field with the masked amount is called "betrag"
the hidden field (type = hidden input) is called "paypalamount"

In the field "betrag" I put in like you said:

function ff_betrag(element, action)
{
var val = element.value;
var price = val.replace(",",".");
var paypal_val = price.replace("€","");
ff_getElementByName('paypalamount').value =paypal_val;
}


To show if I get the correct result, I created a summarized field, to show the hidden field, but it is empty. Also if I change the last line of the script (just to try) to:
ff_getElementByName('paypalamount').value =100;

So I am not shure. Maybe it is working, because I can not show the hidden field!!??
But I am not shure, because I want to check the content of the hidden field. So how can I dow this?

Thank you for your answer in advance

Please Log in or Create an account to join the conversation.

Validating money amount with masked field 3 years 7 months ago #222464

  • marko.bosnjak
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 2222
  • Karma: 44
  • Thanks: 279
Hi again,

there's a mistake in the first line of your script.
Instead of:
function ff_betrag(element, action)
there should be:
function ff_betrag_action(element, action)
You're missing the "_action" part.
For checking if the hidden element is working, when in admin preview, right click somewhere in the form and select "Inspect". The browser console will open and then search for the element called "ff_nm_paypalamount". It's type is "hidden". The value should dynamically change based on the value from the "betrag" element.
So, if the value is specified 10,00€:



the console should output this:



Try it out and let me know if it's OK now.

Regards,
Marko
======================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
======================================
Need to renew Pro Support?
Buy Here!
======================================
Satisfied?
Consider a Membership!
======================================
Follow us on Facebook!
Attachments:
The following user(s) said Thank You: SNuuDA

Please Log in or Create an account to join the conversation.

Last edit: Post by marko.bosnjak.
  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.103 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!