Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
why is my input always showing me this data-val-required?

I have created a nullable corporateSponsorName. However, I am not able to have an empty value to my database.. when I tried console.log, it shows me "" which the actual code did not mention "data-val="true" data-val-required="The Corporate Sponsor Name* field is required.""

may i know how to turn off that data-val-required?

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

As this document said:

Beginning with .NET 6, new projects include the <Nullable>enable</Nullable> element in the project file. Once the feature is turned on, existing reference variable declarations become non-nullable reference types.

In .NET 6 the non-nullable property must be required.

To achieve your requirement, you can remove <Nullable>enable</Nullable> from your project file (Right-click on the project name in the Solution Explorer, and then select Edit Project File from the menu).

Another way is that you can add ? to allow nullable, e.g:

public class Test
{
    public string? Name { get; set; }
    public string? Id { get; set; }
    //other proerpties..
}

If you do not use .NET 6, it will not make property required by default unless you add [Required] attribute on the property.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!