question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTML5 validation with required doesn't show error

See original GitHub issue

steps to reproduce

  1. Create `<textarea name="source" required="required"></textarea>
  2. Bind summernote.
  3. Send form without filling editor.

browser version and os version and summernote version

What is your browser and OS? All HTML5 validation enabled browsers What is your summernote version? 0.8.8

problem description

When textarea was defined as required, HTML5 validation fails without any notification when editor is not filled. This is caused because HTML5 validation is triggered on source <textarea style="display: none;"> which is not focusable. You can read Chrome error in console:

An invalid form control with name='source' is not focusable.

TODO:

  1. When source textarea is marked as required – remove it from source element and add it to target textarea element.

but it won’t solve problem

  • textarea.note-codable is also not focusable! So even if you rewrite required attr by hand –it won’t show up for Summernote editor.

References: #355 #1201

Similar implementation from other editor: https://github.com/ckeditor/ckeditor-dev/commit/385a822

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

3reactions
drj-iocommented, May 8, 2018

+1

1reaction
joaocariascommented, Mar 31, 2020

use: $(‘#Post’).summernote(‘isEmpty’) || $($(“#Post”).summernote(“code”)).text().trim() == ‘’

Exemple:

$(‘.btn-create’).on(‘click’, function () { var submeterForm = 1; if ($(‘#Post’).summernote(‘isEmpty’) || $($(“#Post”).summernote(“code”)).text().trim() == ‘’) { submeterForm = 0; } if (submeterForm <= 0) { $(‘span[data-valmsg-for=“Post”]’).text(“* Input Required!”); } else { $(‘#form-post’).submit(); } });

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 Reasons - HTML5 Required Attribute Validation not Working
1. The Form Tag has “novalidate” Attribute · 2. Required Attribute Validation doesn't Work with Unclosed Input Tags · 3. The Button is...
Read more >
HTML5 Form Validation - Showing All Error Messages
HTML5 required validation example Open in New Window. Name: Comments: ... Let's see how this can be leveraged to show all error messages....
Read more >
HTML5 Form validation message doesn't show when scroll ...
If the first error field is outside of the viewport then on validation, the document scrolls up and focusses on the field however...
Read more >
Client-side form validation - Learn web development | MDN
What is form validation? ... Go to any popular site with a registration form, and you will notice that they provide feedback when...
Read more >
HTML5 Form Validation Examples < HTML - The Art of Web
Different browsers may mark the input box in some way (Firefox 4 Beta adds a red box-shadow by default), display a warning (Opera)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found