victorjonsson / jQuery-Form-Validator

[DISCONTINUED] jQuery plugin that makes it easy to validate user input while keeping your HTML markup clean from javascript code.
972 stars 476 forks source link

BUG: data-validation="confirmation" #595

Closed dubalizer closed 7 years ago

dubalizer commented 7 years ago

Hi

When using the form setup below, the "Password Confirm" -field get status "valid" when filling in the first field "test 1":

  <form action="" role="form">

    <div class="form-group">
      <label class="control-label">test 1</label>
      <input class="form-control" name="test1" type="text" data-validation="length" data-validation-length="min3" />
    </div>

    <div class="form-group">
      <label class="control-label">E-mail</label>
      <input class="form-control" name="email" type="email" data-validation="email" />
    </div>

    <div class="form-group">
      <label class="control-label">Password</label>
      <input class="form-control" name="password_confirmation" type="password"
             data-validation="length"
             data-validation-length="min5"
             data-validation-error-msg="You have not given a correct password" />
    </div>

    <div class="form-group">
      <label class="control-label">Password Confirm</label>
      <input class="form-control" name="password" type="password"
             data-validation="confirmation" data-validation-confirm="password_confirmation" />
    </div>

    <div class="form-group">
      <button type="submit">Login</button>
      <button type="reset">Reset</button>
    </div>

  </form>
victorjonsson commented 7 years ago

This is not to be considered a bug. The validator confirmation does not mark the input as invalid due to the simple fact that the values of the two inputs are the same. I guess it's something like this you're after

http://jsbin.com/rudesuxova/edit?html,console,output

victorjonsson commented 7 years ago

The documentation on formvalidator.net sends you off in the wrong direction with this validator. I will update the example code...

dubalizer commented 7 years ago

Thank you for your answer.

It's almost as I would like to have it in your example above: http://jsbin.com/rudesuxova/edit?html,console,output

But, is it possible to have each one of the password inputs to validate one at a time. For example:

Password (length="min5") should be set to valid when 5 characters are given (regardless of the confirmation input). Password Confirmation (confirmation) should be set to valid as well after they match.

So when all fields are written, they should all have green borders.

Thanks for your time.

victorjonsson commented 7 years ago

Ah, that is why one would want to put the confirmation validator on the other input. Then you probably should rethink why you want the confirm-input to be marked as invalid when it actually is valid... Maybe this example meets your demands (adding the length validator also to the confirming input) http://jsbin.com/mahuhakave/edit?html,console,output?

dubalizer commented 7 years ago

Thank you so much for all your help. Now it works flawless.