2

I've created a survey with rating questions and branch logic and most are required fields. Any suggestions/ideas on how to use Javascript/JQuery to change the OOTB required field user message "You must specify a value for this required field" ?

Thanks in advance

  • can you share some bits of the html source around the field validator? – Tiago Duarte Jul 31 '14 at 21:15
1

this will be attached specifically to surveys and you can tweak both types of messages

<script type="text/javascript">
$(document).ready(function () {

        //override: "You must specify a value for this required field."

        //per-field validator
        $('.ms-formbodysurvey .ms-formvalidation > span[role="alert"]').text("Please specify a value for this field.");

        //summary validator
        $('.ms-formbodysurvey span.ms-formvalidation[role="alert"]').text("Please make sure all required fields are properly filled.");

});
</script>
  • I just added this code to change alert in newForm.aspx "You must specify a value for this required field". Unfortunately, after applied this code Formula column Validation in my form not working. Any solution? – Ameenah Alley Sep 9 '17 at 7:37
  • I can't think of a reason why this would break something, unless of course you don't have jquery and the $ is breaking your scripts. check the console for errors – Tiago Duarte Sep 10 '17 at 9:22
0

You can use this code. You should add this to both NewForm.aspx and EditForm.aspx.

<script type="text/javascript">
$(document).ready(function(){

var alertSpan= $('span[role="alert"]');
alertSpan.text('My Custom Alert!');

});
</script>

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.