Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showErrors not working on groups #129

Open
will-attitude-marketing opened this issue Sep 8, 2023 · 1 comment
Open

showErrors not working on groups #129

will-attitude-marketing opened this issue Sep 8, 2023 · 1 comment
Labels

Comments

@will-attitude-marketing
Copy link

Describe the bug
I have a multiple checkbox group and used .addRequiredGroup() to make it required.

Submitting the form using the submit button works as expected: i see the required error message for the multiple checkbox

When I try to manually show the error using showErrors, I get the following error: Field not found. Check the field selector.

An example of the bug using the playgroud(https://just-validate.dev/playground):

function Demo(props) {
  onLoad(() => {
    const validator = new JustValidate('#basic_form');
    validator
      .addField("#txtInput",  [{ rule: 'required' }])
      .addRequiredGroup("#checkboxes","this is required");
    setTimeout(() => { 
      validator.showErrors({  "#txtInput": "input error", "#checkboxes":"errors", } );      
    },1000);   
    
  });

  return (
    <form id="basic_form" autocomplete="off" novalidate="novalidate">
    <div>
      <input type="textbox" id="txtInput"/>
    </div>
      <div id="checkboxes">
      <input type="checkbox" id="checkbox_option[0]" />
      <input type="checkbox" id="checkbox_option[1]" />
      <input type="checkbox" id="checkbox_option[2]" />
      <input type="checkbox" id="checkbox_option[3]" />
      </div>
      <div class="control-wrapper">
        <button type="submit" class="button">
          Submit
        </button>
      </div>
    </form>
  );
}
@horprogs
Copy link
Owner

horprogs commented Nov 2, 2023

Hey, unfortunately currently there is no support for showing error messages for groups

@horprogs horprogs added the bug label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants