Questions tagged [required]

Required is an HTML attribute of an input element that forces that the input be supplied.

Required fields are a common form of front-end validation to prevent users from submitting data that is logically incomplete. Though making fields required may not be an end-all validation technique, it is sufficient in a large number of cases.

839 questions
83
votes
4 answers

Required and Optional Arguments Using Boost Library Program Options

I'm using Boost Program Options Library to parse the command line arguments. I have the following requirements: Once "help" is provided, all the other options are optional; Once "help" is not provided, all the other options are required. How I can…
Peter Lee
  • 11,507
  • 7
  • 65
  • 97
74
votes
7 answers

Explain why constructor inject is better than other options

In a Pro Spring 3 Book, Chapter 4 - Introduction IOC and DI in Spring - Page 59, In "Setter Injection vs. Constructor Injection" section, a paragraph says Spring included, provide a mechanism for ensuring that all dependencies are defined when …
minil
  • 6,115
  • 15
  • 45
  • 55
73
votes
9 answers

Conditionally required property using data annotations

I have a class like this: public class Document { public int DocumentType{get;set;} [Required] public string Name{get;set;} [Required] public string Name2{get;set;} } Now if I put a [Required] data annotation on the Name and Name2…
brtb
  • 1,772
  • 5
  • 28
  • 50
57
votes
7 answers

Is the 'as' keyword required in Oracle to define an alias?

Is the 'AS' keyword required in Oracle to define an alias name for a column in a SELECT statement? I noticed that SELECT column_name AS "alias" is the same as SELECT column_name "alias" I am wondering what the consequences are of defining a…
Jonathan
  • 8,402
  • 8
  • 49
  • 64
45
votes
5 answers

Django: Make certain fields in a ModelForm required=False

How do I make certain fields in a ModelForm required=False? If I have: class ThatForm(ModelForm): class Meta: widgets = {"text": Textarea(required=False)} Or if I have: class ThatForm(ModelForm): text = Textarea(required=False) Django…
Synthead
  • 1,777
  • 4
  • 18
  • 25
41
votes
8 answers

HTML5 required attribute seems not working

I can't figure out why the new required attribute of HTML5 seems to not be working, and I know my simple code seems to be okay. What should I do to make this work? Here is my code in HTML:
HTTP
  • 1,478
  • 3
  • 14
  • 21
36
votes
5 answers

Angular is automatically adding 'ng-invalid' class on 'required' fields

I am building an angular app for which I have some forms set up. I have some fields that are required to be filled before submission. Therefore I have added 'required' on them:
Spearfisher
  • 7,303
  • 17
  • 59
  • 115
31
votes
2 answers

When to use the required attribute vs the aria-required attribute for input elements?

I'm trying to make a form accessible. Should I make my inputs have both required and aria-required attributes, or just one? Or like this?
Ralph David Abernathy
  • 4,472
  • 7
  • 42
  • 67
31
votes
4 answers

Enforce not-null field in JSON object

Our REST API receives some JSON objects input where some fields are required to be not null. Those can be either String/Integer or even might be some other class instance as reference. We are trying to find a way to enforce those field to be not…
urir
  • 1,860
  • 3
  • 19
  • 39
30
votes
3 answers

@Autowired vs @Required on setter

I'm curious to know what's the difference between code like this: class MyClass { @Autowired MyService myService; } and code like this: class MyClass { MyService myService; @Required public void setMyService(MyService val) { …
0x56794E
  • 19,267
  • 12
  • 39
  • 53
29
votes
8 answers

textarea's "required" attribute doesn't work even though the value is empty

I created a simple page with list box and text area with conditions that all should be required. List box are working fine, but textarea box doesn't tell that the field is required to be filled. Ratings &…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/html" class="post-tag grid--cell" title="show questions tagged 'html'" rel="tag">html</a> <a href="../../questions/tagged/textarea" class="post-tag grid--cell" title="show questions tagged 'textarea'" rel="tag">textarea</a> <a href="../../questions/tagged/required" class="post-tag grid--cell" title="show questions tagged 'required'" rel="tag">required</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 12 '13 at 08:56">asked Jun 12 '13 at 08:56</time> <a href="../../users/2264834/divakar-scm" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2264834.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="divakar.scm" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/2264834/divakar-scm" class="s-user-card--link">divakar.scm</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,074</li> <li class="s-award-bling s-award-bling__gold" title="4 gold badges">4</li> <li class="s-award-bling s-award-bling__silver" title="18 silver badges">18</li> <li class="s-award-bling s-award-bling__bronze" title="32 bronze badges">32</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <div class="s-pagination--item is-selected">1</div> <a class="s-pagination--item" href="../../questions/tagged/required_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/required_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/required_page=55" rel="" title="Go to page 55">55</a> <a class="s-pagination--item" href="../../questions/tagged/required_page=56" rel="" title="Go to page 56">56</a> <a class="s-pagination--item" href="../../questions/tagged/required_page=2" rel="next" title="Go to page 2"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script> /* replace <time class="fromnow" /> with human delta between `datetime` attr and now */ document.addEventListener('DOMContentLoaded', function(){ var time_elements = document.querySelectorAll("time.fromnow"); for (var i=0; i<time_elements.length; i++) { time_elements[i].innerHTML = moment(time_elements[i].getAttribute("datetime")).fromNow(); } }); </script> </body> </html>