How can I display an error message using Javascript?


Here is the code I’ve tried but the message does not get displayed when the conditions are met. 

$(“.sg-error-message”).text(“Test error message”).fadeIn(“slow”);


Jim W (Moderator) answered

    Hi Nicole,

    Your fellow SurveyGizmo users will need more details about your survey and the script’s role in it.

    What are the conditions  that are supposed to be met?  Where in relation to these conditions are you placing the script?  Is fading-in an error message the best way to get your user’s attention?

    nicole commented
      • Hi Jim, I have a textbox grid question that is not mandatory. I am doing my own checks for valid entries and would like to display survey gizmo’s error message when conditions are not met. I’ve since learned that the line of code above simply changes the error message text and is not the result I’m looking for. Is there a way to show the error message at my discretion? Thanks.


      Hi Nicole,

      I am not a coding expert, but if I had to develop a similar script I would probably not worry about the SurveyGizmo error message and use the jquery text method to display my own  messages.

      I don’t know enough about what you are trying to achieve with your survey to provide you with good technical guidance, but I can offer an informed (probably biased) opinion.  I would avoid using the textbox grid question and use a custom group question if possible.  This is my preference because, unlike the fields in the text box grid, I can use HTML placeholders to inform respondents about their expected input and then use validation routines to manage their actual inputs.  This would also remove the need for a custom JavaScript to validate responses.

      Jim W (Moderator) answered


        Question stats

        • Active
        • Views4523 times
        • Answers2 answers
        • Followers1 follower