This topic is locked

error with currency fields using , or .

2/18/2005 9:30:07 AM
ASPRunnerPro General questions
Pfeiffer author

Hello,

in my database I have a currency field which is displayed in View as

12,99. When opening EDIT-mask the value is displayed too as 12,99.

When I try to save the record, the validate.html is not accepting 12,99 but

is accepting 12.99.
So have to change all times the value from 12,99 to 12.9 when I edit the record ???

In all views this field is set to Currency.
I use MYSQL-Tables with double-Fields.
Please help.
Greetings

Uwe Pfeiffer

Sergey Kornilov admin 2/21/2005

Uwe,
validation routine expects currency and floating value fields to use dot as a separator. You can modify validate.htm to use comma or dot for this purpose.
See my changes in bold:

   else if(validateObject.type == "IsMoney")

   //IsMoney tells whether a field is a currency field or not

   {

  var moneyPass=true;

  var dotFound=false;

  var dotFoundAt=-1;

  var strField = new String(validateObject.val);

 Â

  var k = 0;
  for (k = 0; k < strField.length; k++)

  {

    var x=strField.charAt(k);

    if (x == "." || x == ",")

    {

   dotFound = true;

   if (dotFoundAt < 0)

   {

     dotFoundAt=k;

   }

    }

    if (((x < '0') || (x > '9')) && (x != '.' && x != ','))

    {

   errors += validateObject.HTMLname + "\n";

   MoneyMsg += validateObject.HTMLname + "\n";

   k = strField.length;

    }

    if ((x == '.' || x == ',') && (dotFoundAt != k))

    {

   errors += validateObject.HTMLname + "\n";

   MoneyMsg += validateObject.HTMLname + "\n";

   k = strField.length;

    }

  }

   }

Pfeiffer author 2/21/2005

Hello,

I tried your changes to , instead of . but now you get an SQL-Error by updating a

record, because in the SQL-Syntax the , is now interpreted as a field separator.
So your solution doesn't work.
I think you should convert curreny values from , to . within the

getdata-Function. I will try this way...
Thanks

Uwe