Script that observes the changes in the textbox field | XM Community
Skip to main content
I am currently implementing a question of type multiple choices(single answer) with 3 choices. First choice is a radio button with a text entry which asks for MM/YYYY as a date. The other two options are radio buttons, viz Dont know and Refuse to answer. I need to write a script that would validate the date. So, basically I want write a script that observes the changes in the textbox field. Whenever a user types in the textbox, it should validate the date and if validation is correct, it should allow the user to proceed to next page. I need to write an observe event that would continuously observe the changes made to textbox when the first radio button is selected, and if other buttons are selected it should erase the textbox content.
@srane Not sure where you are starting from but here is some of the basics of capturing the change events (NOTE: you will need to replace (_ with { and _) with } in the code below since this forum does not allow curly brackets within posted code...access denied error).



var qid=this.questionId; // question ID of the currently selected question

// NOTE: this change event will fire if the user changes the textbox value

jQuery("input[id='QR\\~"+qid+"']").change(function() (_

var txtVal = jQuery("input[id='QR\\~"+qid+"']").val();

alert(txtVal); // let us know when the text value is changed

_)

Leave a Reply