ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

submitting a negative number in Safecracker form

August 25, 2011 7:50am

Subscribe [3]
  • #1 / Aug 25, 2011 7:50am

    hi everyone!

    I hope this is something very simple.. i need to submit a negative number as a text input value in Safecracker filed, who can i achieve this?
    i tried so far:

    <input name="expense" id="expense" type="text"  value="-{expense}" />

    but i need to hide the “-” sign from the field. Thanks!

    Dmitry

  • #2 / Aug 25, 2011 6:33pm

    Dan Decker

    7338 posts

    Dmitry,

    I can offer a couple of suggestions. If you are working on the assumption that {expense} is always a negative number, then you could make the minus sign the label for the field, rather than trying to include it as part of the field value. If you know it will always be treated as a negative value, there really is no benefit in trying to store it as a negative value. Does that make sense?

    Since this question falls more in line with “how to” and not a technical issue with ExpressionEngine, I’m going to move it into Community Help to keep the discussion going.

    Cheers,

  • #3 / Aug 25, 2011 6:42pm

    Mark Bowen

    12637 posts

    As Dan says if the number will always be a negative number then don’t worry about it as it’s always going to be a minus number then this is something you can deal with at the template level when you come to outputting the number.

    On the other hand if you have to have it as a minus number then you would probably either need to use some javascript to make it convert to that upon submitting the form (sorry can’t help there as my Javascript isn’t all that good) or better would be to create an extension which adds in the minus symbol upon submitting an entry.

    Best wishes,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases