CalcBuilder Forum

Need help formatting inches and feet in textarea

User moon_1512 2014-03-21 05:36:46

Hello, I have a calculator with a description section that is a textarea. In this section, users enter data such as 3'2" x 3"3" . But as you know, special characters like " and ' escape and cause the data to be truncated. I know how to format numbers because of your examples like "$inline1=number_format($inline1,2,".",",");". How then can I format my textarea field to not escape my special characters?

Moonsoft support 2014-03-21 10:01:28

in fact single quotes are not affecting to text formatting at textarea, while double quotes do. As a workaround you can automatically replace double quotes for a couple of single ones, so the whole information introduced at the textarea can travel without problems. Assumming your textarea field has the name 'area', you can add this line to the javascript tab 'executed before calculate execution':

CB("textarea").val(CB("textarea").val().replace(/\"/g, "''"));

(replace the both 'area' name for your own field name). This should do the work.


User moon_1512 2014-03-21 15:29:45

Took a little while to get working but works like a charm now. Thanks! I had 6 description fields. They were description1, 2, 3, etc. But by adding the JS for just description1, all of the other fields worked as well. Great component and Great support!

Moonsoft support 2014-03-21 15:46:48

Great it worked, thanks for the feedback. Not sure of why it worked for the other fields, in case you need to apply the replace for them, just add more lines changing the fldname property for each one.

Thanks, regards


Create dynamic calculators

Buy now!
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!