Willkommen, Gast
Angemeldet bleiben:

THEMA:

Validating money amount with masked field 4 Jahre 6 Monate her #222289

  • Autor
  • SNuuDA
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Beiträge: 18
  • Dank erhalten: 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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Validating money amount with masked field 4 Jahre 6 Monate her #222290

  • marko.bosnjak
  • Offline
  • Benutzer ist gesperrt
  • Benutzer ist gesperrt
  • Beiträge: 2222
  • Karma: 44
  • Dank erhalten: 280
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!

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Letzte Änderung: Post by marko.bosnjak.

Validating money amount with masked field 4 Jahre 6 Monate her #222306

  • Autor
  • SNuuDA
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Beiträge: 18
  • Dank erhalten: 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.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Validating money amount with masked field 4 Jahre 6 Monate her #222336

  • marko.bosnjak
  • Offline
  • Benutzer ist gesperrt
  • Benutzer ist gesperrt
  • Beiträge: 2222
  • Karma: 44
  • Dank erhalten: 280
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!
Folgende Benutzer bedankten sich: SNuuDA

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Validating money amount with masked field 4 Jahre 6 Monate her #222424

  • Autor
  • SNuuDA
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Beiträge: 18
  • Dank erhalten: 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

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Validating money amount with masked field 4 Jahre 6 Monate her #222464

  • marko.bosnjak
  • Offline
  • Benutzer ist gesperrt
  • Benutzer ist gesperrt
  • Beiträge: 2222
  • Karma: 44
  • Dank erhalten: 280
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!
Anhänge:
Folgende Benutzer bedankten sich: SNuuDA

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Letzte Änderung: Post by marko.bosnjak.
  • Seite:
  • 1
  • 2
Moderatoren: ForumSupport
Ladezeit der Seite: 0.111 Sekunden

Angebot

Sommer Special! Alle Mitgliedschaften zum Sonderpreis!

Prio Support, alle Extensions und alle Templates in einem Paket.

Hier geht's zur Bestellung

Crosstec hilft sparen!

Falls Sie neu bei Crosstec sind aber bereits einen Formulargenerator bei einem anderen Hersteller gekauft haben, dann bekommen sie von uns einen Rabatt von 25% auf unsere 1-Jahres und Pro-Mitgliedschaften

Wie Sie an den Rabatt kommen?

Schreiben Sie uns einfach eine kurze Email mit beigelegten Kaufbeleg (z.B. PayPal Quittung) an sales@crosstec.org.

Wir unterstützen die Joomla Community

Crosstec unterstützt weltweit alle offiziellen Joomla! User Groups und Organisatoren von Joomla! Days die bei Joomla.org registriert sind.

Falls das auf dich zutrifft und du eines unserer Produkte brauchst, schreib uns eine kurze Email an info@crosstec.org und du bekommst eine Flatrate-Mitgliedschaft geschenkt!