Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Formular-Validierung (nicht vs. falsch ausgefülltes Pflichtfeld) #8044

Closed
Anke opened this issue Oct 1, 2015 · 6 comments
Closed

Formular-Validierung (nicht vs. falsch ausgefülltes Pflichtfeld) #8044

Anke opened this issue Oct 1, 2015 · 6 comments
Assignees
Labels
Milestone

Comments

@Anke
Copy link

Anke commented Oct 1, 2015

Zum Thema Formularvalidierung und Zurückspringen an den Seitenanfang (anstatt zur Fehlermeldung):

Bei der HTML5-Validierung geht der Fokus zum ersten Pflichtfeld, das nicht ausgefüllt wurde. Wird aber z.B. die Captcha-Frage falsch beantwortet, springt die Seite zurück an den Anfang. (Ich nehme an, das ist auch bei anderen Feldtypen so.)

Wenn die HTML5-Validierung keine falsch ausgefüllten, sondern nur leere Pflichtfelder erkennt, ist es da nicht sinnvoll, eine ergänzende JS-Kontrolle in den Core mit aufzunehmen? Sonst hat man immer wieder ein Problem bei langen Formularen oder One-Page-Websites.

@leofeyer leofeyer added this to the 3.5.7 milestone Dec 23, 2015
@leofeyer
Copy link
Member

@contao/developers /cc

@aschempp
Copy link
Member

ganz klar nein. die HTML5-Validierung kann auch deaktiviert werden.

Wir hatten in Contao 2.11 (wenn ich mich richtig erinnere) aber ein Snippet drin, welches jeweils zum ersten Fehler-Feld gescrollt ist. Ich glaube das hatten wir nur wegen jQuery entfernt, wäre ggf. sinnvoll als Vanilla wieder einzubauen.

@leofeyer leofeyer modified the milestones: 3.5.7, 3.5.8 Feb 29, 2016
@leofeyer leofeyer modified the milestones: 3.5.9, 3.5.10 Mar 21, 2016
@leofeyer leofeyer removed this from the 3.5.10 milestone Apr 19, 2016
@leofeyer
Copy link
Member

leofeyer commented Aug 11, 2016

As discussed in Mumble on August 11th, we should add this script in the form.html5 template as it used to be in 683d3f9. However, it should be VanillaJS instead of MooTools or jQuery.

@ausi
Copy link
Member

ausi commented Sep 20, 2016

The VanillaJS version could look like this:

try {
  document.querySelector('#<?= $this->formId ?> .error').scrollIntoView();
} catch(e) {}

scrollIntoView and querySelector are supported in all major browsers.

@leofeyer leofeyer added this to the 4.3.0 milestone Sep 20, 2016
@leofeyer
Copy link
Member

Thank you @ausi.

leofeyer added a commit to contao/core-bundle that referenced this issue Oct 28, 2016
leofeyer added a commit to contao/comments-bundle that referenced this issue Oct 28, 2016
leofeyer added a commit to contao/newsletter-bundle that referenced this issue Oct 28, 2016
@leofeyer
Copy link
Member

Implemented in contao/core-bundle@01d5598.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants