Separating dollars and cents in a form text entry | XM Community
Skip to main content
I am asking respondents to input a price in a text entry (form) type question, but I want a separate entry box for dollars and for cents, with the two boxes appearing side-by-side, with a dollar sign in front of the dollars box and a decimal point in between the two boxes, and I need to be able to do custom validation separately for the allowable values in the dollars box entry and the allowable values in the cents box. Then I need to assign the combined price to an embedded data field. Any advice on how do to this would be much appreciated.
Hello @BradyDar ,



Step 1: Use "Text Entry" -> "Form" with form field count as "2" question setup.



Step 2: Paste the following code in the js(OnReady) of the Text entry question type



var that = this.questionId;

jQuery("#"+that+" .ControlContainer").css("white-space","nowrap");

jQuery("<span>$</span>").insertBefore(jQuery("#"+that+" .InputText:eq(0)"));

jQuery("#"+that+" .InputText:eq(1)").insertAfter(jQuery("#"+that+" .InputText:eq(0)"));

jQuery("<b>.</b>").insertAfter(jQuery("#"+that+" .InputText:eq(0)"));

jQuery("#"+that+" .ReadableAlt").hide();



Step 3: Output

!

Leave a Reply