-1

For the following input field ...

<input type="text" value="" name="registerModel.Name" id="registerModel_Name" placeholder="Your display name" class="form-control" aria-required="true">

... I have added a simple validation rule:

$('input[name="registerModel.Name"]').rules('add', {
        required: true,
        messages: {
            required: "Required input"
        }
    });

The validation works, when i click the submit button of the form it's not send:

<input type="text" value="" name="registerModel.Name" id="registerModel_Name" placeholder="Your display name" class="form-control input-validation-error" aria-required="true" aria-describedby="registerModel_Name-error" aria-invalid="true">

But the error message is not displayed.

It's a bootstrap form but i didn't have any problems with jquery validation and bootstrap in the past.

I'd appreciate help very much.

<form method="post" enctype="multipart/form-data" action="/" id="formvalidatemember" novalidate="novalidate">
    <div class="form-group">
         <label class="form-control-label col-sm-3" for="registerModel_Name">Your name</label>
         <div class="col-sm-9">
            <input type="text" value="" name="registerModel.Name" id="registerModel_Name" placeholder="Your display name" class="form-control" aria-required="true">
         </div>
    </div>
    <div class="col-sm-offset-3 col-sm-9">
       <button class="btn btn-secondary buttonSendForm" type="submit">Register</button>
     </div>
</form>

$(function () {
 $("#formvalidatemember").validate();
 $('#registerModel_Name').rules('add', {
  required: true,
  minlength: 6,
  messages: {
   required: "Required input",
   minlength: jQuery.validator.format("Please, at least {0} characters are necessary")
  }
 });
});
Anja
  • 473
  • 4
  • 12
  • It's working perfectly fine for me: http://jsfiddle.net/k5dqqhaq/ Did you remember to first initialize the plugin using the `.validate()` method? Otherwise, show enough code to reproduce the issue. – Sparky Oct 20 '15 at 01:27
  • Thank you for the example. I have bootstrap 4alpha. Seeing that it works find for you I just start wondering if that may be the reason for the issue. – Anja Oct 20 '15 at 01:34
  • I've shown that the posted code is working, so now the burden is on you to provide us with just enough code to reproduce the problem. Otherwise, the question is unlikely to be helpful to anyone. Thanks. – Sparky Oct 20 '15 at 01:51
  • Found the following entry about bootstrap 3 and jquery validate: http://stackoverflow.com/questions/18754020/bootstrap-3-with-jquery-validation-plugin. I tried, but it doesn't work. So maybe the reason is that i am using bootstrap 4. – Anja Oct 20 '15 at 02:24
  • Your updated code is still working fine: http://jsfiddle.net/syf67o6m/ If you want help, you'll have to create a demo that shows the problem. – Sparky Oct 20 '15 at 05:29

1 Answers1

0

I upgraded jquery validation to the newest version and now it works. Very sorry.

Anja
  • 473
  • 4
  • 12