© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
141 replies
Mek

✅ ✅ Issues With Input Validation

public static string? VerifyEmptyOrChanged(string? oldEntry, string newEntry)
{
    if (String.IsNullOrEmpty(newEntry) || newEntry == oldEntry)
    {
        return oldEntry;
    }
    else
    {
        return newEntry;
    }
}
public static string? VerifyEmptyOrChanged(string? oldEntry, string newEntry)
{
    if (String.IsNullOrEmpty(newEntry) || newEntry == oldEntry)
    {
        return oldEntry;
    }
    else
    {
        return newEntry;
    }
}
I'm asking the user for information when they select to update an entry within the database. Their instruction is to just press enter and leave the entry blank if they want to keep the information the same, however, I also need this function to check a date format and a time format (two separate checks) and I can't figure it out. To clarify, The first entry is asking them for an adjusted date, or to leave it empty. When they put in something, it needs to check if that entry is empty or not and whether it matches
MM/dd/yyyy
MM/dd/yyyy
format. Then it asks them for the updated start time, or to leave it empty. That needs to check if the entry is empty and whether it matches
HH:MM
HH:MM
format and same for the third check. Thanks
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Issues with DataAnnotationsValidator and ValidationSummary
C#CC# / help
2y ago
❔ Issues with model state validation
C#CC# / help
3y ago
Menu Validation 'char input'
C#CC# / help
16mo ago