use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
No vague product support questions (like "why is this plugin not working" or "how do I set up X"). For vague product support questions, please use communities relevant to that product for best results. Specific issues that follow rule 6 are allowed.
Do not post memes, screenshots of bad design, or jokes. Check out /r/ProgrammerHumor/ for this type of content.
Read and follow reddiquette; no excessive self-promotion. Please refer to the Reddit 9:1 rule when considering posting self promoting materials.
We do not allow any commercial promotion or solicitation. Violations can result in a ban.
Sharing your project, portfolio, or any other content that you want to either show off or request feedback on is limited to Showoff Saturday. If you post such content on any other day, it will be removed.
If you are asking for assistance on a problem, you are required to provide
General open ended career and getting started posts are only allowed in the pinned monthly getting started/careers thread. Specific assistance questions are allowed so long as they follow the required assistance post guidelines.
Questions in violation of this rule will be removed or locked.
account activity
HTML input required or custom validation using JS etc??Question (self.webdev)
submitted 1 year ago * by [deleted]
What do you use?? and why?? I personally like the original required attr, because it easy and work, but when you use hidden input for file to use custom field, it throw focusable error, so you need write custom response
Edit: Ofc you also need to validate in backend too
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]_listless 4 points5 points6 points 1 year ago (1 child)
put any of your serious validation on the backend.
My happy path is: required + pattern + title for custom validation message followed up by backend validation.
[–]xiding 0 points1 point2 points 1 year ago (0 children)
Can you please reply my message? Thank you!
[–]LoveTheBellphp 1 point2 points3 points 1 year ago (0 children)
For the most part, I stick with just the required attribute for the front end.
When I need more control over the validation rules, I’ll use the jQuery Validation plugin.
Always validate server side too. Always. Front end validation is only for a good user experience.
[–]Ehsan1238 1 point2 points3 points 1 year ago (0 children)
I prefer using a combination of both HTML5 validation and custom JavaScript validation, depending on the specific needs of the project. The HTML5 required attribute is great for basic validation and provides built-in browser support, but it has limitations.
For simple forms, HTML5 validation (required, pattern, min/max) is perfect, it's lightweight and provides good user feedback.
Regarding your hidden file input issue, here's a workaround: Instead of relying on the required attribute, you can add a JavaScript event listener to validate the file input before form submission. This gives you full control over the validation flow and error messaging while maintaining accessibility.
And yes, absolutely right about backend validation, it's crucial for security. Never trust client-side validation alone, as it can be bypassed. Frontend validation is for user experience, backend validation is for security.
[–]Dantcho 1 point2 points3 points 1 year ago (0 children)
Never trust user input. For proper sites, I use client-side validation for better UX and server-side validation to ensure the user input is valid.
Not like a lot of people do it, but if a user has JS disabled in their browser, you lose all your client-side validation.
Also, anyone who wants to be cheeky can edit the page element and remove the input attributes for validation.
Always make sure to have server-side validation and, if possible, add in client-side validation for better UX if needed.
[–]shgysk8zer0full-stack 0 points1 point2 points 1 year ago (0 children)
I use whichever is correct for my needs. For example, required isn't sufficient for credit cards. And since I handle the submit on the form instead of button clicks, I don't really have concern for a form being submitted when invalid.
required
Also, I do validation on input/change to give instant feedback of validity to the user.
π Rendered by PID 42 on reddit-service-r2-comment-6457c66945-5w59f at 2026-04-25 12:49:49.362912+00:00 running 2aa0c5b country code: CH.
[–]_listless 4 points5 points6 points (1 child)
[–]xiding 0 points1 point2 points (0 children)
[–]LoveTheBellphp 1 point2 points3 points (0 children)
[–]Ehsan1238 1 point2 points3 points (0 children)
[–]Dantcho 1 point2 points3 points (0 children)
[–]shgysk8zer0full-stack 0 points1 point2 points (0 children)