Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Pre-fill a Numeric Q with a “£” symbol?

I have followed the advice here

 to constrain the decimal places for currency values in a numeric question (‘val’):
    var response = $('#val').val();
    var regex = /\.[0-9][0-9]$/;
    if (!regex.test(response))
        strErrorMessage = 'Error text here.';

I would like to pre-fill the response box with a “£” symbol on the left.

Is that possible with a numeric Q? – I think it’s been done in a Grid Q:


asked Oct 13, 2016 by dan r Bronze (4,025 points)

1 Answer

0 votes
Best answer
Put these codes in your question footer:

    $('#NumericQ_div input').wrap('<span class="currencySpan"></span>');

.currencySpan {
    border: 1px inset #ccc;

.currencySpan input {
    border: none;

.currencySpan input:focus {
    outline: none;

"NumericQ" should be replaced with the numeric question's name.

Does this look sufficient for you?  I can keep experimenting with the CSS if you want to modify how it looks.
answered Oct 13, 2016 by Zachary Platinum Sawtooth Software, Inc. (205,975 points)
selected Oct 13, 2016 by dan r
That works  and looks fine to me Zachary - thank you

Would you be able to give the code to implement the same in a Grid Q set up for numeric input?

If you have removed the alternating colors from the grid question, you can probably use almost the exact same code.  Instead of "#NumericQ_div input", you need this:

#GridQ_div .inner_table input

If you are using background colors in the grid, though, more CSS may be necessary to make it look good.
works for me, as is.