PDA

View Full Version : Case Sensitive(Lower OR Upper)


Abd
04-22-2003, 09:26 AM
Hi All,

Please how do I force the data that is been type into a textfield a particular case, either Lower OR Upper case?

Thanks
Abd

raf
04-22-2003, 10:17 AM
With Ucase() and Lcase()

More info from helpfile
-------------------------------------------------
LCase()

Description
Returns a string that has been converted to lowercase.
Syntax
LCase(string)
The string argument is any valid string expression. If string contains Null, Null is returned.

Remarks
Only uppercase letters are converted to lowercase; all lowercase letters and nonletter characters remain unchanged.

The following example uses the LCase function to convert uppercase letters to lowercase:
Dim MyString
Dim LCaseString
MyString = "VBSCript"
LCaseString = LCase(MyString) ' LCaseString contains "vbscript".

--------
UCase()

Description
Returns a string that has been converted to uppercase.
Syntax
UCase(string)
The string argument is any valid string expression. If string contains Null, Null is returned.

Remarks
Only lowercase letters are converted to uppercase; all uppercase letters and nonletter characters remain unchanged.
The following example uses the UCase function to return an uppercase version of a string:

Dim MyWord
MyWord = UCase("Hello World")

Abd
04-22-2003, 12:57 PM
thanks raf, but how do I use the LCase() or UCase with a control like Name:<input type="text" name="user" size="15">

Abd

christrinder
04-22-2003, 01:00 PM
I'm not expert, but I would assume that there is no way to control what it looks like when they type in the box, but if on the action page you put something like:

objRS.Fields("user") = Lcase(request.form("user"))

It will convert what they type to lower case before it inserts it into the database.

Chris

raf
04-22-2003, 02:21 PM
Not sure what you're trying to do. Do you want A) to show the text in a textbox (like when you select text from a db or a form and you display it in a textbox), or would B)you like the text that user type in to be in displayed as upper or lowercase wwhen the are typing, or C)do you want a value from a textfield before inserting it?
for A:
<input type="text" name="user" size="15" value="<%= server.HTMLEncode(Ucase(rsRecordsetname.Fields("variable")))%>"> (if it comes from a db)

for C:
variable=replace(UCase(string),"'","''") (replace to deal with the single quotes)
Similar like Christrinders post.

for B:
Hmm. Can probably be done using javascript. But it could be quite confusing to the user. In fact, i can't imagen user having any gain by that. It can be done serversided with a on keydone submit javascriptfunction and then posting it to the same page, but this would generate huge traffic and would be very unpractical and quite ridiculous. This sort a thing is typically something you do behind the screens