You are viewing limited content. For full access, please sign in.

Question

Question

min and max set to same number, need better validation message

asked on August 5, 2016

I have a field that needs to equal 100, I this is the settings:

The problem is that the validation error returns this:

I would like to for the error to be "Value must be equal to 100."

 

 

0 0

Replies

replied on August 5, 2016

There's multiple ways to accomplish this. One way is to plug this code into your form's CSS/JavaScript section:

$(document).on("ready", function() {
  $("#Field1").on("change", function() {
    if (parseFloat($(this).val()) != 100) {
      setTimeout(function() {
        $("#Field1").siblings(".ws-errorbox").find(".ws-errormessage").text("Value must be equal to 100");
      }, 25);
    }
  });
});

Where it says "Field1" you need to change it to the ID of your TotPBasicPercent field. You can find that on the right-hand side of the CSS/JavaScript page (the preview pane). For example, if your field's container has an id of "q45", then your field ID is "Field45".

The above code intercepts the error message and changes it to what you want. An alternative would be to display a pop-up message.

$(document).on("ready", function() {
  $("#Field1").on("change", function() {
    if (parseFloat($(this).val()) != 100) {
      $(this).val("");
      alert("The total basic life insurance percentage must equal 100.");
      $(this).focus();
    }
  });
});

 

0 0
replied on August 8, 2016

I tried the first option, and the error message did not change. 

The other option, although possible, still leaves a rather confusing error on the screen for the user after they click past the alert message.

0 0
replied on August 8, 2016

I worked with this some more and I was able to get it to work .  Thanks you so much.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.