Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restricting text to lowercase in a textbox 2

Status
Not open for further replies.

smurf01

IS-IT--Management
Joined
Jul 6, 2002
Messages
470
Location
GB
Hi,
Is it possible to restrict text to lowercase irrespective of whether the user has the "CAPS LOCK" on or holds down the shift key whilst typing. Even better would be that the first letter of each word would be capitalised whilst the rest of the word would be in lowercase

Any help would be appreciated

Regards

Paul
 
Hey Paul,

I'd use javascript to force lowercase no matter what they type.

One twist to it though, often the onKeyPress will do the lowercase, but when you insert the form, it will revert back to however it was typed.

What i would do is visit the javascript forum, and ask how to convert to lowercase - but also retain that for insertion.

I have some code, but mine changes the first letter of every word to uppercase.

"Never underestimate the power of determination"

Stuart
 
Stuart,
Your Code will do fine all i want to do is restrict them from using all Uppercase. I have some pages that I run which retrieve dynamic data and have set up repeating regions, when they use all Uppercase it uses more room to show the results

Regards

Paul
 
ok, and btw - this credit goes to 2 guys over in the javascript forum.

In the <head> tags.

<script language=&quot;JavaScript&quot;>
function capIt(v)
{
dStuff = (v.value.indexOf(&quot; &quot;)!=-1) ? v.value.split(&quot; &quot;) : v.value;
if(dStuff==v.value){
v.value = v.value.charAt(0).toUpperCase()+v.value.substring(1,v.value.length+1);
}
else {
for (d=0;d<v.value.length;d++)
{
if (v.value.charAt(d) == ' ' && v.value.charAt(d+1))
{
v.value = v.value.substring(0,d) + &quot; &quot; +v.value.charAt(d+1).toUpperCase() + v.value.substring(d+2,v.value.length+1);
}
}

}
}
</script>


and on your text field. Change the name and size to reflect yours.


<input type=&quot;text&quot; name=&quot;txtAddressOne&quot; size=&quot;25&quot; onKeyUp=&quot;capIt(this)&quot;>

&quot;Never underestimate the power of determination&quot;

Stuart
 
credit goes to Dookie2k2 and RISTMO over there, if you found it helpful, please star the two.

thread216-437557 &quot;Never underestimate the power of determination&quot;

Stuart
 
Just use this

<input type=&quot;text&quot; name=&quot;caps&quot; size=40 value=&quot;&quot; onChange=&quot;javascript:this.value=this.value.toLowerCase();&quot;>
 
or even more simple.

let them input it anyway you feel like - or they feel like.

then on the output.

just do LCase

<%=Lcase(Recordset1.Fields.Item(&quot;fldName&quot;).Value)%>

You can actually do this inside databindings.

When you put the recordset field in place, in the databindings window - look right you'll see a format column. click the down arrow next to that field, select alphaCase - select lower.

Regards

Paul
 
darn it, it switched usernames on us again smurf.

The above wasnt smurf, it was me. &quot;Never underestimate the power of determination&quot;

Stuart
 
Stuart,
your Java script code works great except if the user puts &quot;CAPS LOCK&quot; on, then the text remains in uppercase Regards

Paul
 
actually I never tried that,

well the out pouring from database using LCase will work 100% of the time. &quot;Never underestimate the power of determination&quot;

Stuart
 
Stuart,
Can I add the LCase code Manually as The Text Field is not Dynamic. The User enters data into an Insert Record Form. If so where would I place it

Regards

Paul
 
if its an insert record - is it not going into a database?

&quot;Never underestimate the power of determination&quot;

Stuart
 
Yes, but if I add the recordset field into the textfield, when my insert form opens it shows the first record text in the field. I would like the field empty when the form opens Regards

Paul
 
you lost me

are you doing an edit form? &quot;Never underestimate the power of determination&quot;

Stuart
 
Stuart,
Sorry I'll try and explain. I have created an Access Database to store information on Machine Maintenance, I have also created some search pages and results pages + an insert record form and an update form. On the insert record form i have the following

1. Dynamic list for machine ID
2. TextField showing the current date
3. Dynamic list for Item Id
4. Textfield for typing the Request (this is where i want to restrict the use of capitals)
5. Dynamic list for User Initial entering data
6. textfield for Comments ( also want to restrict CAPS here)
7. Dynamic list for Status
8. textfield showing Username

therefore when the insert record form opens the Request field and the comments field are empty, when i used the recordset field and entered it into the request textfield and tested it. The form opened with the text from the first record of my databse showing in the request field. that is why I asked if i could enter the code manually.

Onse again sorry for any confusion i have caused and i hope this helps to explain better Regards

Paul
 
Ok,

I believe so,

Well your left with 2 options really,

First is to do the output with Lcase - and as long as you see
<%=recordset...........

then yes you can manually add Lcase( to it.

but if there is no <%=recordset.... present - than no - it only works for dynamic data.

Your other option is on the insertion side, with javascript. I see you posted on that thread over in javascript forum - hopefully one of those guys can give you a quick answer.

On a side note - did you test mxJunkies code on insertion? &quot;Never underestimate the power of determination&quot;

Stuart
 
Stuart,
Thanks for the help. BTW no I have not tried out mxjunkies code yet but I will Regards

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top