hi anyone here knows how to validate user inputs.. when the user logs in and his/her password is in Uppercase(saved in database) but forgets to type in uppercase. and it would display warning message saying invalid password...

any help would be highly appreciated :)

Dani AI

Generated

Quick summary and safe recommendation based on the replies: there are four practical ways to handle this. 1) Make comparisons case‑insensitive at the database level (what hinted at). 2) Compare case‑insensitively in the application layer (similar idea to ). 3) Force the UI to accept only uppercase (like suggested). 4) Better long‑term: stop storing plain text passwords and migrate to a salted, slow hash (raised by ). Each choice has tradeoffs; security and future maintainability should guide the decision.

Important security notes: never keep passwords as plain text. Move to a modern password‑hashing approach (PBKDF2/bcrypt/Argon2) and a per‑user salt. If the legacy system requires case‑insensitive checks, canonicalize input before hashing (for example, ToUpperInvariant or ToLowerInvariant) and apply the same canonicalization when creating or verifying hashes. Canonicalizing for passwords reduces entropy, so avoid it unless necessary. For details on secure storage patterns see the OWASP guidance: Password Storage Cheat Sheet.

Where to put the logic and simple, safe options: do the comparison on the server in your authentication routine (login button handler or auth service), not only in client code. If you must accept uppercase-only legacy passwords, set the UI control to uppercase rather than rewriting its text on every change (this avoids caret jumps and reentrancy). In WinForms you can set the property once:

TextBox1.CharacterCasing = CharacterCasing.Upper

For a server-side, case-insensitive check (if chosen), compare canonicalized strings:

If String.Equals(userInput.Trim(), dbValue.Trim(), StringComparison.OrdinalIgnoreCase) Then
    ' authenticated
End If

If you consider changing SQL Server collation, test thoroughly. Altering collation can affect indexes and other behavior; use a per-query COLLATE or change a single column first. See Microsoft docs on collations for the implications and steps: .

Recommended Answers

All 8 Replies

You need to change the collation at the server.

how do i change the collation?

are you storing the actual password in database as is ?

>>how do i change the collation
read the link provide by adatapost

in addition, you can use string compare function.

Dim i As Integer
i = String.Compare("dani", "DaNi", False)
If i = -1 Then
   MsgBox("Different")
ElseIf i = 0 Then
   MsgBox("Same")
End If

i did set it to collation..i followed the procedure..

where will i put this code in my program?

Dim i As Integer
i = String.Compare("dani", "DaNi", False)
If i = -1 Then
   MsgBox("Different")
ElseIf i = 0 Then
   MsgBox("Same")
End If

no, that just an example code. i just show how to use string compare.
you need to modified it.

Dim i as Integer
Dim PassResult as String

PassResult = (a password taken from database, select result)
i = String.Compare(txtPassword.Text, PassResult, False) ' compare an inputed password with a password from database
If i = -1 Then
   MsgBox("Wrong Password")
ElseIf i = 0 Then
   ' same password, do anything as u wish 
End If
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        TextBox2.Text = UCase(TextBox2.Text)
    End Sub

just make your textbox in uppercase...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.