Skip to content

Commit d1a569f

Browse files
committed
fix: revert back to find id anywhere in document
1 parent 81a4cb6 commit d1a569f

6 files changed

+6
-10
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Version 1.7 adds x-required directive for toggling if the field is required.
2424
* 1.7.20: added observer for `required` attribute on fields and `disabled` attribute on fields and fieldsets. Now x-validate reacts to changes to these attributes so you can use AlpineJS :required and :disabled to set them.
2525
* 1.7.22: added `validate-on-submit` option to automatically validate on submit
2626
* 1.7.23: fix for submit so that it double checks validation on fields. There was a bug where if the user hit return and didn't tab out of a field it didn't update.
27-
* 1.7.26: fix for 1.7.25 break. Also fixes issue for multiple forms so that error messages have unique ids
27+
* 1.7.27: fix for 1.7.25 break where id based error messages stopped working. Also fixes issue for multiple forms so that error messages have unique ids.
2828

2929
## Simple Usage
3030

dist/alpine.validate.cjs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,7 @@ var Plugin = function(Alpine) {
338338
}
339339
function getErrorMsgFromId(field) {
340340
const id = getAttr(field, "id");
341-
const form = getForm(field);
342-
return form.querySelector(`#${ERROR_MSG_CLASS}-${id}`);
341+
return document.getElementById(`${ERROR_MSG_CLASS}-${id}`);
343342
}
344343
function addErrorMsg(field) {
345344
const fieldData = getData(field);

dist/alpine.validate.esm.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ var Plugin = function(Alpine) {
325325
}
326326
function getErrorMsgFromId(field) {
327327
const id = getAttr(field, "id");
328-
const form = getForm(field);
329-
return form.querySelector(`#${ERROR_MSG_CLASS}-${id}`);
328+
return document.getElementById(`${ERROR_MSG_CLASS}-${id}`);
330329
}
331330
function addErrorMsg(field) {
332331
const fieldData = getData(field);

dist/alpine.validate.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/alpine.validate.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@
326326
}
327327
function getErrorMsgFromId(field) {
328328
const id = getAttr(field, "id");
329-
const form = getForm(field);
330-
return form.querySelector(`#${ERROR_MSG_CLASS}-${id}`);
329+
return document.getElementById(`${ERROR_MSG_CLASS}-${id}`);
331330
}
332331
function addErrorMsg(field) {
333332
const fieldData = getData(field);

src/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,7 @@ const Plugin = function (Alpine) {
605605

606606
function getErrorMsgFromId(field) {
607607
const id = getAttr(field, "id");
608-
const form = getForm(field);
609-
return form.querySelector(`#${ERROR_MSG_CLASS}-${id}`);
608+
return document.getElementById(`${ERROR_MSG_CLASS}-${id}`);
610609
}
611610

612611
/* ------ Function to setup errorMsgNode by finding it or creating one ------ */

0 commit comments

Comments
 (0)