Placeholder text
-
Hi,
Thank you for this great plugin.
Can you please enable us to add placeholder text?
Thank you
Best regards,
Jovan
-
Hi Jovan,
You want the labels inside the input fields, instead of above the fields?
Guido
Hi Guido,
1)
Yes.
If you could add another list of options for the placeholder text as well.
Then, the user can add both if he wants to.
https://www.w3schools.com/tags/att_input_placeholder.asp2)
For the labels, the colon ‘:’ symbol is unessesairy.
It’s added automatically, but sometimes it doesn’t fit the design.
Also, it may not be grammatically correct for all languages.3)
It would be nice to have a few additional custom fields, to ask the user a question, like:
– Your location
– Your budget
– Where did you hear about us
– …4)
Would be nice to have a redirect to a page after the from has been submitted.5)
I know that you want the from to be super lite.
And that’s why I like it.
But, how about giving the user the option to inject a little bit of JS that prevents the page from being closed if someone started writing, but did not submit the form.
Or maybe they clicked the button, but it didn’t send.
And they try to leave quickly without realizing that it didn’t get sent."use strict"; (() => { const modified_inputs = new Set; const defaultValue = "defaultValue"; // store default values addEventListener("beforeinput", (evt) => { const target = evt.target; if (!(defaultValue in target || defaultValue in target.dataset)) { target.dataset[defaultValue] = ("" + (target.value || target.textContent)).trim(); } }); // detect input modifications addEventListener("input", (evt) => { const target = evt.target; let original; if (defaultValue in target) { original = target[defaultValue]; } else { original = target.dataset[defaultValue]; } if (original !== ("" + (target.value || target.textContent)).trim()) { if (!modified_inputs.has(target)) { modified_inputs.add(target); } } else if (modified_inputs.has(target)) { modified_inputs.delete(target); } }); // clear modified inputs upon form submission addEventListener("submit", (evt) => { modified_inputs.clear(); // to prevent the warning from happening, it is advisable // that you clear your form controls back to their default // state with evt.target.reset() or form.reset() after submission }); // warn before closing if any inputs are modified addEventListener("beforeunload", (evt) => { if (modified_inputs.size) { const unsaved_changes_warning = "Changes you made may not be saved."; evt.returnValue = unsaved_changes_warning; return unsaved_changes_warning; } }); })();
I was just plaining to answer your question, but then got these ideas ??
If it had all this, it would be the perfect form plugin.Regards,
JovanHi Jovan,
1) I can add (shortcode) attributes for every field, so you are able to add a placeholder text for every field.
But I cannot simply remove/disable the labels (Name, Email, etc) because of accessibility reasons. So if user only wants placeholders, without labels, best thing to do is to hide the labels. Because this way the labels are still available for screen readers.2) I agree, guess best thing to do is remove them. They almost have no added value.
3) Main reason for developing this plugin was to create a (very) simple contact form plugin with default fields only. So I have to think about this.
4) I have to think about this.
5) Idem.. But to be honest, I don’t want to add lots of extra stuff, so I don’t think I’m gonna add this.
Guido
Hi Guido,
1) Right, labels are needed for accessibility.
You can give the option to ‘hide the labels’, which just adds the class ‘screen-reader-text’.
Each theme should have this set up in the reset stylesheet.
https://make.www.ads-software.com/accessibility/handbook/markup/the-css-class-screen-reader-text/3) What’s another few fields…? It’s still simple, but much more powerful.
5) Yea, I didn’t think you would want to add the script. Maybe link to a code snippet with it, if you have a blog or something like that.
6) Just remembered something. No reason for the width of these input fields to be 80%.
#vscf .form-group input[type="text"], #vscf .form-group input[type="email"] {width:80%; box-sizing:border-box; font-family:inherit; font-size:1em;}
Regards,
Jovan3) Besides my explanation earlier, it’s a lot of work to properly add extra fields. Maybe in the future.
6) I think a wider textarea field looks better, instead of the same width for all fields.
Will add a placeholder feature, working on it already ??
Guido
Great!
I really appreciate the work you’ve done, the work you’re doing currently and what you have planed for the future ??
Jovan
Hi Jovan,
Have just updated plugin. 1 and 2 are taken care of.
You can activate placeholders via plugin settingspage.
Please let me know how this works for you. It seems a minor update, but it was quite some work, so hopefully everything (still) works fine.
Guido
Hi Guido,
Thank you! Your work is very appreciated ??
The placeholder text works well.
Tested on two sites.
Looks fine on one… but breaks the layout on my test site.
Seems to be an error in the html.
The div ‘vscf-name-group’ is appearing twice.
First one is acting as a wrap.
But, it doesn’t close and drags elements below it into the container.Hopefully, you’ll be able to see this in the cached and non-cached versions of the page.
If you disable the flexbox, the page looks ok.
But, the info should be on the left, contact on the right and the map below (outside of the flexbox).
Broken (cached): https://2test.live/contact/
Rolled back to previous version (escaped cache): https://2test.live/contact/?=lkgkjHTML in inspector:
https://i.postimg.cc/z5rcNZJd/VSCF.jpgJovan
Hi Jovan,
You’re right, a mistake in the HTML of the form! Did not notice this, so thanks for that ??
Will update plugin again today..
Guido
Hi Guido,
Glad to be of assistance ??
Jovan
Hi Guido,
For hidden labels, you’re adding the class ‘vscf-hide’, which has the property ‘display: none’.
Screen readers don’t see this, as if it’s not in the html!
Text that is meant only for screen readers should only be moved outside of the viewport or reduced to 1px.
This is how Elementor does it:
.elementor-screen-only, .screen-reader-text, .screen-reader-text span, .ui-helper-hidden-accessible { position: absolute; top: -10000em; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
Jovan
Hi Jovan,
Thanks again! To be honest, I already knew this, but was not certain how to include this properly. Wanted to work on this in the near future.
Guess best thing to do is to include the default screen reader CSS in my plugin, instead of using the
.screen-reader-text
class only and depend on theme stylesheet. And remove thedisplay:none;
from those elements.My themes use this:
.screen-reader-text {position:absolute; overflow:hidden; height:1px; width:1px; margin:-1px; padding:0; clip:rect(1px, 1px, 1px, 1px); clip-path:inset(50%); word-wrap:normal;}
Guido
Hi Guido,
I assumed that you did know, cause I saw that you develop themes as well.
I realize that I send unessesairy links and explain basic stuff.
It’s not because I think that you don’t know.
It’s one part habit, but more to be absolutely clear in what I’m saying.Agreed. A single CSS rule for a custom class is the safest way to handle this.
Jovan
Hi Jovan,
But often users can help and guide the developer, so many thanks ??
It turns out te be quite easy to make this work:
I will add the screen reader CSS to plugin stylesheet, for existing class.vscf-hide
. For the 2 fields that should be ignored by screen readers (timetrap and nonce) I will add a new class called.vscf-display-none
to both fields with CSSdisplay:none;
. Guess this way accessibility is taken care of, all field labels are readable this way.Did you stumple upon other stuff? Otherwise I will update plugin ASAP again.
Guido
Hi Guido,
Sounds like a good plan.
I didn’t see any other issues.
Jovan
- The topic ‘Placeholder text’ is closed to new replies.