Is there a way for me to make the first letter in a field capital if the user forgets to make it capital? For example, in my form there is a field for the first name. I'd like to enter some type of Java Script so when the user tabs off the field & the first letter is not capital, it will make it capital. If I don't have to use Java Script that will be fine too.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
If it is just a one word value then you could use this in the exist event;
this.rawValue
= util.printx(">?<*",this.rawValue);
This changes the first character (represented by the ?) to uppercase (represented by the >) and all trailing characters (represented by the *) to lowercase (represented by the <).
If you wanted something more general ... if they could also enter a middle name then you could call a function like;
function
toTitleCase(textValue)
{
return
textValue.toLowerCase().replace(/\b[a-z]/g, function replacer(match) { return match.toUpperCase(); });
}
This uses a regex to change all lowercase letters following a word boundary to uppercase.
Bruce
Views
Replies
Total Likes
Hi,
If it is just a one word value then you could use this in the exist event;
this.rawValue
= util.printx(">?<*",this.rawValue);
This changes the first character (represented by the ?) to uppercase (represented by the >) and all trailing characters (represented by the *) to lowercase (represented by the <).
If you wanted something more general ... if they could also enter a middle name then you could call a function like;
function
toTitleCase(textValue)
{
return
textValue.toLowerCase().replace(/\b[a-z]/g, function replacer(match) { return match.toUpperCase(); });
}
This uses a regex to change all lowercase letters following a word boundary to uppercase.
Bruce
Views
Replies
Total Likes
I couldn't get that code to work. Does anyone know of any JavaScript code to make the first letter in each text box capitalized?
Views
Replies
Total Likes
The 1st example in Bruce's post works perfectly. I think that is exactly what you are looking for. Just put the following code into the 'exit' event of your field and set the Language drop-down to JavaScript:
this.rawValue = util.printx(">?<*",this.rawValue);
As soon as you exit the field the first letter is set to uppercase. I just tested it right now and it worked nicely.
I found this Formcalc script in another forum:
Surname = Concat(upper(Left(Surname,1)),lower(Right(Surname,Len(Surname)-1)))
Change Surname to your field name
Here's a link to the thread:
Views
Replies
Total Likes
I tested this script, there's an error in it. It should be:
Surname = Concat(Upper(Left(Surname,1)), Lower(Right(Surname,Len(Surname)-1)))
again with Surname being the field name. This script caps the first letter in the field and makes all other letters lowercase.
Views
Replies
Total Likes
Just wanted to thank you for your detailed answer. It worked for me too
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies