how to get numbers from a form text field using BreezingForms in Joomla?

SilverNodashi

Expert Member
Joined
Oct 12, 2007
Messages
3,340
Reaction score
48
Location
Johannesburg, South Africa
Does anyone know, or use BreezingForms, on Joomla?


How do I get only numbers from a text field? i.e. a user types in R40, how do I only get the "40" part of it?

I tried the following, but it just gives me "NaN" as response:

PHP:
function ff_Total12_validation(element, message)
{
    ff_wendy_calculate12();
    if (element.value==0) {
        ff_validationFocus('Price12');
        return message;
    } // if
    return '';
} // ff_Total12_validation

function ff_wendy_calculate12()
{
    var amount12 = 0;
    var order12;
    var price12;

    qty12 = Number(ff_getElementByName('QTY12').value);
    price12 = Number(ff_getElementByName('Price12').value);
    if (qty12 != '') amount12 += parseInt(qty12) * Number(parseInt(price12));

    ff_getElementByName('Total12').value = Math.round(amount12*100)/100;
    ff_OrderTotalAmount_validation();

} // ff_wendy_calculate12

A few google searches suggest that the "Number()" function could do this, but it doesn't seem to work. I'm using Joomla 1.5.15 + BreezingForms 1.7.1 Stable (build 730) [Trinity]
 
Last edited:
Is this PHP or Javascript? It looks like Javascript, but you've said PHP?

Anyway, in Javascript, the Number function does not strip out the letters, it only converts a character representation of a number into a number, ie, the string "123" into the number 123.

Write your own function to strip out non numeric characters before passing to Numbers();

If you need help with that just shout.
 
Top
Sign up to the MyBroadband newsletter
X