Design comparison
Solution retrospective
-
Should I include a
<form>
element? I didn't put in one, because the page doesn't submit any data from the inputs. -
Does the "Select Tip %" has to be a
<label>
. If yes, what should I give for it'sfor
attribute. -
The input fields are text type. I originally wanted to use number type, but then the spin buttons show up. When I searched for a way to remove it, the only way I found was a non-standard one(
::-webkit-outer-spin-button
pseudo-element). Is there a proper way to do it? -
I gave
inputmode="numeric"
for the input fields, since I couldn't set them totype="number"
(because of the spin buttons), but the w3c validator gives a warning since it's not supported by every browser. Is there a better way for this whole number type input field? -
It's a broad question, but is there any problem with my script? Until now I only wrote 10-20 line scripts with simply one or two event listeners (I tried to provide proper description with comments).
Thank you for the feedback.
Community feedback
- @tan911Posted almost 2 years ago
Hello @Decimo-10, Here's my suggestion that might improve your applications also to answer some of your questions as well.
- I think you should, and they should be inside the fieldset if you want to make "Select Tip %" a label. Also you can use
input="radio"
for every percentage and hide it via visually-hidden class or sr-only class instead of normal button element and don't forget to add label to every input radio button. - You can use javascript to handle the validations for the input type text. If you do this, then you have to check if the input value can be converted by a number or not. If it is, do the calculations otherwise just give an error message there. When providing an error message you can add aria-describeby to your input element with the same value to the id of your error message or to your span element. This will benificial to your audience who use screen readers.
<div class="label-wrapper"> <label for="bill-input" class="input__label">Bill</label> <span id="your-error" class="input__error-message">Can't be zero</span> </div> <input type="text" id="bill-input" aria-describedby="your-error" class="input__field" placeholder="0" inputmode="numeric" pattern="[1-9][0-9]*\.?[0-9]*">
Marked as helpful1 - I think you should, and they should be inside the fieldset if you want to make "Select Tip %" a label. Also you can use
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord