Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to add .required span to comment textfield?
Tagged: asterisk, comment, comment form, required, text field
- This topic has 15 replies, 2 voices, and was last updated 10 years, 2 months ago by Brad Dalton.
-
AuthorPosts
-
September 24, 2014 at 6:15 pm #125603September 24, 2014 at 6:43 pm #125604Brad DaltonParticipantSeptember 24, 2014 at 7:02 pm #125607EscendrixMember
Thanks Brad!
I don't know much about php, but I am intermediate with CSS/ HTML. How would I go about making a field required with your code? I see the line that contains the .required span class but they aren't "active" so to speak.
September 24, 2014 at 7:10 pm #125608Brad DaltonParticipantSeptember 24, 2014 at 7:24 pm #125609EscendrixMemberSorry, I guess I should have been more clear that I don't know PHP at all 😛 , so technically speaking I haven't done anything besides searching on Google to no avail.
September 24, 2014 at 7:40 pm #125611Brad DaltonParticipantYou could add an asterisk using this code http://wpsites.net/web-design/customize-comment-field-text-area-label/
I suggest you install WordPress locally or use a test site to test code modifications if you want to make the changes to your theme yourself.
September 25, 2014 at 12:43 am #125632EscendrixMemberHmm it seems like that tutorial is more about styling the look and text of the comment field; I couldn't find anything about making a field required. I've already styled my forms and made them how I want, I just wanted to add that .required span to the comment text area so that it would have an asterick like my other required text fields. I understand that you can't submit a form without a comment, so it seems very strange that Genesis doesn't add the required class to the comment text area by default.
I could easily change the label to have one by default without using the class, but for learning purposes I want to figure out how to add the actual span class if possible.
I am developing my WordPress site locally with Wamp server so there's no problem there.
September 25, 2014 at 12:46 am #125633Brad DaltonParticipantSeptember 25, 2014 at 12:47 am #125634EscendrixMemberNow that I think about it, I guess the bigger question to ask is how to go about changing the default comment form to use a plugin's comment form, such as Ninja Forms, but maybe that should be for another topic. Maybe the long-term solution is to learn PHP and code my own form structure, but that's not an option at this point. I'm trying to get my website up quickly and I've pretty much finished the custom style sheet already. I don't want to delay the development by learning a new language, although I want to at some point.
September 25, 2014 at 12:48 am #125635EscendrixMemberI could do that, but I was trying to figure out how to add the .required class instead.
September 25, 2014 at 1:30 am #125636EscendrixMemberI actually found this: https://core.trac.wordpress.org/ticket/16206 but I'm not sure if making modifications directly to WordPress would be a good idea and I'm not sure how to go about implementing that through my child theme's functions.php file.
September 25, 2014 at 1:39 am #125637Brad DaltonParticipantThe code i linked to enables you to change the text label so you can also add an asterisk.
Please mark this as resolved and ask a new question if needed.
September 25, 2014 at 1:45 am #125638EscendrixMemberMaybe I'm not being more clear, if so I apologize.
As I've said before, I completely understand that I can modify the label to add an asterisk, but that's not what my original question was about. To me, that's more of a "hack".
The reason I opened this topic was to find out why WordPress does not add the .required span to the comment text area, and how I could go about adding it. I don't want to modify the label, I want to add the .required span that are used for the name and email text fields.
I hope I have made myself more clear for you, sorry for any confusion.
September 25, 2014 at 2:36 am #125640Brad DaltonParticipantI think its already included which you can see if you look at the code. The only thing which isn't is the *
September 25, 2014 at 3:16 am #125641EscendrixMemberIf the code is there, then why are they not showing up? There is a comment at the very bottom by "Hassan" that is having the same problem as me.
Furthermore, your tutorial and code was specifically for name, email, and website text fields, but I want the class to be added to the comment box as well.
September 25, 2014 at 3:35 am #125643Brad DaltonParticipant -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.