Is there a way in the Bootstrap-5 world to indicate a input field is required?

4,423 views
Skip to first unread message

Charles Severance

unread,
Nov 19, 2022, 9:43:27 AM11/19/22
to dev sakai
Something like this:

<div id="title-group" class="form-group required">
<label for="title" class="form-control-label">Value</label>
<div>
<input type="text" class="form-control" id="title" th:value="${tenant.title}” required />
</div>
</div>

Could we add something like this to our CSS? Or is it in B5 already?

Thanks.

/Chuck

Kunal Jaykam

unread,
Nov 19, 2022, 9:48:48 AM11/19/22
to Sakai Development, csev
You might want to take a look at this: 


Hope that helps.

Kunal Jaykam

Charles Severance

unread,
Nov 19, 2022, 10:07:01 AM11/19/22
to dev sakai, Kunal Jaykam
I have read that page over and over for several hours this morning :)  Nothing about the asterisk in the UI to indicate required.

/Chuck

Kunal Jaykam

unread,
Nov 19, 2022, 10:14:47 AM11/19/22
to Sakai Development, csev, Kunal Jaykam

Markus Stetschnig

unread,
Nov 21, 2022, 2:45:24 AM11/21/22
to Charles Severance, dev sakai

Hey Chuck,

what would be the goal with the required class? I didn't see it in B3 and neither in the deprecated Bootstrap classes.
Do you mean we could add CSS rules to style required inputs differently? B5 does not have that built in. I think selecting 'input.form-control:required' would make sense in that case.
As for validation, the browsers validation will still work though.

Does that answer your question or is it about something else?

Markus

Markus Stetschnig

unread,
Nov 21, 2022, 3:45:43 AM11/21/22
to saka...@apereo.org

Yes, for that case we would need to add custom CSS. Unfortunately this will also require it it's own CSS class without making use of the :has selector.

--
You received this message because you are subscribed to the Google Groups "Sakai Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sakai-dev+...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/sakai-dev/3E4DA7E1-A2AE-4689-B84A-6891548D1536%40umich.edu.

Charles Severance

unread,
Nov 21, 2022, 6:46:45 AM11/21/22
to Markus Stetschnig, dev sakai
<div id="title-group" class="form-group required"> 
<label for="title" class="form-control-label">Value</label> 
<div> 
<input type="text" class="form-control" id="title" th:value="${tenant.title}” required /> 
</div> 
</div> 

You add “required” to the enclosing div.   Perhaps I should name it something else like form-group-required…

WDYT?

/Chuck

Markus Stetschnig

unread,
Nov 21, 2022, 7:02:00 AM11/21/22
to Charles Severance, sakai Development

Nice, maybe we could rename it to .form-control-required? The .form-group class CSS was removed with B4, so maybe we shouldn't require it?

I am not sure if --bs-danger is mapped to any Sakai theme color. --sakai-highlight-color would also be an option.

Charles Severance

unread,
Nov 21, 2022, 7:37:10 AM11/21/22
to Markus Stetschnig, dev sakai
I made a JIRA to clean this up.


Feel free to comment on the JIRA.

/Chuck
Reply all
Reply to author
Forward
0 new messages