Using FormValidation with a partially pre-filled form, how can add checks to valid fields?

272 Views Asked by At

I have certain fields (like "firstName") which I can pre-fill. However, I would like to check these against FormValidation and visually show the users which fields are complete. When I pre-fill the field, however, no visual feedback is given until I press Submit. I tried "checkValidation" but this does not do the trick.

$('#firstName')[0].checkValidity();

<input type="text" class="form-control" id="firstName" name="firstName" placeholder="First name" value="@ViewBag.FirstName" />

I tried delaying filling the value until after the validation script, but this does not help either.

1

There are 1 best solutions below

0
On

You can manually trigger the formValidation feedback. See this example:

        $('#myUpgradeForm').formValidation('revalidateField', 'firstName');

More Info: http://formvalidation.io/examples/