Is there a way to change the message that appears when the data entered into a form field does not match the format or regular expression I have assigned? Currently it simply displays a message "Invalid input." I would like to change that to something more descriptive. For example in the image below the format must be 111.111.1111, I would like the error message to display more then "Invalid input."
Question
Question
Forms invalid input message
Answer
Hi Jessica,
You could use the following CSS to append an informational message to the error text:
p.ws-errormessage::after {content:"/*More information goes here.*/";}
That would add the informational message to all such "Invalid input" messages, however. You can prepend the relevant selectors before that line of CSS to restrict to a particular field if desired; for example, after adding the "fax" class to the "Fax Number" field and the "phone" class to the "Phone Number" field, the CSS code
.fax p.ws-errormessage::after { content:"Please enter the fax number in the form xxx.xxx.xxxx"; } .phone p.ws-errormessage::after { content:"Please enter the phone number in the form (xxx) xxx-xxxx"; }
yields the following results:
Hope this helps!
Note that as of Forms 10.2 you can specify custom validation messages for input fields at both the process and form level.
Replies
instead of trying to change the error message, why don't you use java to update the field format automatically to the desired format?
Preview:
instruction here on how to setup field masks:
Here is the java code to use (make sure you download the jquery plugin as instructed in the help file from above):
assuming your field has a class name of fax
$(document).ready(function () { $.getScript ('http://changetoyourformservername/Forms/js/jquery.mask.min.js', function () { $(".fax input").mask("999.999.9999"); }); });
This would be a great idea except that they are using these for postal codes wich are a mixture of numbers and letters. Thanks.
Right, it depends on the field. I think being able to provide more detailed messages is still important though. For instance, in the sample jQuery Mask they've set up, the mask for the Date field does not specify whether it is MM/DD/YYYY format or DD/MM/YYYY. And if I were to enter in, say, 1 3 15 for March 1st, 2015 (going day-month-year), it would wind up masked as 13/15 - not even a complete date.
After some piddling around, I may find that 01/03/2015 is an accepted value. Unbeknownst to me, though, this is registering as January 3rd, 2015, because the value is being interpreted month-day-year. (And that's not even something that can be handled exclusively through regular expressions!)
Of course the best way to handle fields in general would be some combination of a more forgiving mask set up, better error reporting, and better labelling outlining exactly how the information should be entered in. That latter goes a long way to avoiding headaches on both the user side ("How should I enter it in?") and the surveyor side ("How do I let users know what I'm expecting?").