jQuery Validate Not Working After AJAX Loaded Form – Common Mistakes and Fix
You load a form using AJAX, try to submit it, and jQuery Validate does nothing. No errors, no highlighting, no messages. This happens because jQuery Validate binds itself to elements that exist when the plugin is initialized. If the form appears later via AJAX, validation will not work unless you attach it again or initialize it the right way.
Let’s go through the most common mistakes and how to fix them.
1. Initializing jQuery Validate before the form exists
This is the number one cause.
Bad example:
$('#registerForm').validate({
rules: { name: 'required' }
});
If AJAX loads the form after this code runs, there is no element to attach to and jQuery Validate silently fails.
Fix: initialize after AJAX completes
$.get('/register/form', function (html) {
$('#formContainer').html(html);
$('#registerForm').validate({
rules: { name: 'required' }
});
});
Always initialize inside the AJAX callback or after you inject the HTML into the DOM.
2. Using .on('submit') without preventing default
Many developers do this:
$('#registerForm').on('submit', function () {
// custom logic
});
If you return false or submit via AJAX, jQuery Validate might never run.
Better pattern
Let jQuery Validate control submission:
$('#registerForm').validate({
submitHandler: function (form) {
form.submit();
}
});
If you want AJAX submit:
$('#registerForm').validate({
submitHandler: function (form) {
$.ajax({
url: form.action,
method: 'POST',
data: $(form).serialize(),
success(data) { console.log('Saved'); }
});
}
});
Do not mix manual .submit() bindings and validation.
3. Missing name attributes on inputs
jQuery Validate targets inputs by name, not id.
Bad form:
<input id="email" type="email">
No name = no rule binds.
Correct:
<input id="email" name="email" type="email">
Without name, validator ignores that field.
4. Replacing form content without destroying validator
When you reload or swap forms dynamically, old validator instances may still exist.
Clean way
$('#formContainer').html(formHtml);
$('#registerForm').removeData('validator');
$('#registerForm').removeData('unobtrusiveValidation');
$('#registerForm').validate({
rules: { name: 'required' }
});
Removing validator data prevents old configs from interfering.
5. Dynamically added fields after validation
You add more inputs via AJAX or JS. Validator doesn’t know them unless you add rules manually.
Example:
$('#phone').rules('add', {
required: true,
minlength: 10
});
You can also reinitialize the validator, but adding rules is cleaner.
6. Wrong selector for the form container
Many times the form is inside a dialog, modal, or nested container that changes after AJAX.
Example:
$('#modal form')
If modal is not in DOM yet, validator sees nothing.
Fix: bind after modal injects the form:
$('#myModal').on('shown.bs.modal', function () {
$('#registerForm').validate({ ... });
});
7. Using validate() on the wrong element
You must call .validate() on the <form> tag, not a div, modal wrapper, or container.
Bad:
$('#formContainer').validate();
Correct:
$('#formContainer form').validate();
8. Laravel Blade validation errors interfere
If you load forms from Laravel using AJAX and include Blade validation messages, duplicate id or fields can cause weird behavior.
Make sure:
- No duplicated
idon inputs - No extra hidden
_tokenfields with same id - Modal forms replaced, not stacked
9. Page caching or Turbolinks
SPA frameworks (Inertia, PJAX, Turbolinks, HTMX) can cache pages and break script reloading.
Solution is always the same:
Initialize validator after content render.
Example with Vue SPA:
nextTick(() => {
$('#registerForm').validate({ ... });
});
10. Use ignore: [] when validating hidden fields
Default jQuery Validate ignores hidden inputs.
If your form has hidden fields that must validate:
$('#registerForm').validate({
ignore: [],
rules: {
token: { required: true }
}
});
Final Working Example
AJAX loads form → init validator → submit via AJAX:
$.ajax({
url: '/profile/form',
success(html) {
$('#modalBody').html(html);
$('#profileForm').validate({
rules: {
email: {
required: true,
email: true
},
name: 'required'
},
submitHandler(form) {
$.post(form.action, $(form).serialize(), function (res) {
alert('Saved!');
});
}
});
}
});
This pattern works reliably: wait for HTML → bind validation → handle submission.
Quick checklist
- Initialize validate after AJAX injects the form
- Ensure inputs have
nameattributes - Bind to the form element, not a wrapper
- Avoid manual
submithandlers blocking validation - Destroy old validators before reinjecting forms
- Add rules for dynamic fields
- Use
.on(modal.open)for modals - Check hidden fields and ignore rules if required
Once validator is reattached to the AJAX-loaded form, validation messages will show and submission will work normally.