#49039 closed enhancement (duplicate)
JavaScript/jQuery validation for comment form
Reported by: | guddu1315 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.3.1 |
Component: | Comments | Keywords: | |
Focuses: | ui | Cc: |
Description
Hello,
When a user tries to submit the comment form with blank values. He/She is redirected to domain.com/wp-comments-post.php which is quite bad in terms of UI/UX.
As the user is redirected to another page and then he comes back to the same page.
So basically we redirect the user to another page just to show the error messages.
It would be great if we can manage validations using JavaScript or jQuery.
So the user gets the error messages on the same page he doesn't have to go anywhere.
Thank you.
Attachments (2)
Change History (6)
#2
in reply to:
↑ 1
;
follow-up:
↓ 4
@
5 years ago
- Summary changed from jQuery validation for comment form to JavaScript/jQuery validation for comment form
Replying to subrataemfluence:
Rather than adding JavaScript validation, what if we go with
required
attributes for mandatory fields.
Hi @subrataemfluence
But considering the old browsers compatibility (https://caniuse.com/#feat=mdn-api_htmlinputelement_required), JavaScript validation would be a better option.
According to https://caniuse.com/#feat=mdn-api_htmlinputelement_required
the browser that don't support required attribute and still in usage is around 27%
27% is a very high number. So that is definitely not an option.
Thanks
#3
in reply to:
↑ 1
@
5 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
Hi there, thanks for the ticket! Just noting this was previously raised in #47728.
Replying to subrataemfluence:
Rather than adding JavaScript validation, what if we go with
required
attributes for mandatory fields.
The comment form does have required
attribute for the <input>
fields, however it also has the novalidate
attribute on the form, which prevents client-side validation from being performed due to concerns about browsers implementing validation in very different ways, per discussion in #15080.
We're now re-evaluating that decision in #47595, let's continue the discussion there.
#4
in reply to:
↑ 2
@
5 years ago
Since @SergeyBiryukov has said that further discussion should be made in #47595, I would just like to share my thoughts:
- The attribute
required
is now been used in most websites these days since HTML5 is now has become the most used one if not the only. So I don't find any negative in using this attribute over JavaScript validation.
- If
required
is the solution, it will only be implemented in the upcoming release and won't be incorporated in older versions of WordPress. Sites developed in 5.3.x will always useHTML5
. Bootstrap usesHTML5
. Modern sites are being developed targeting modern browsers only.
- We also need to remember that a lot of
CSS
rules we are using these days were not previously supported by older browsers. If we take such older browsers into consideration, we have to go back to the old CSS writing styles as well.
I apologize for replying in this ticket.
Replying to guddu1315:
Replying to subrataemfluence:
Rather than adding JavaScript validation, what if we go with
required
attributes for mandatory fields.
Hi @subrataemfluence
But considering the old browsers compatibility (https://caniuse.com/#feat=mdn-api_htmlinputelement_required), JavaScript validation would be a better option.
According to https://caniuse.com/#feat=mdn-api_htmlinputelement_required
the browser that don't support required attribute and still in usage is around 27%
27% is a very high number. So that is definitely not an option.
Thanks
Rather than adding JavaScript validation, what if we go with
required
attributes for mandatory fields.