Jump to content
pilotexpressions

Capitalizing All Letters

Recommended Posts

Hello Logan,

 

How are you doing?

 

I think, you can use the following script (don't forget to change "YOUR_FIELD_NAME" to the name of your field)

<script type="text/javascript">
function capitalize()
{
var fieldname = "YOUR_FIELD_NAME";
fieldname = "InsertRecord"+fieldname;
confirmname = fieldname+"@Confirm";

document.getElementById(fieldname).value = document.getElementById(fieldname).value.toUpperCase();
document.getElementById(confirmname).value = document.getElementById(confirmname).value.toUpperCase();
}
document.getElementById('caspioform').onsubmit=capitalize;
</script>

Fell free to ask, if anything does not work :)

Have a good day!

Share this post


Link to post
Share on other sites

Hello Logan,

 

How are you doing?

 

I think, you can use the following script (don't forget to change "YOUR_FIELD_NAME" to the name of your field)

<script type="text/javascript">
function capitalize()
{
var fieldname = "YOUR_FIELD_NAME";
fieldname = "InsertRecord"+fieldname;
confirmname = fieldname+"@Confirm";

document.getElementById(fieldname).value = document.getElementById(fieldname).value.toUpperCase();
document.getElementById(confirmname).value = document.getElementById(confirmname).value.toUpperCase();
}
document.getElementById('caspioform').onsubmit=capitalize;
</script>

Fell free to ask, if anything does not work :)

Have a good day!

Hi Xiang,

 

I changed the field to the name I'm using and tried the script and it still does not appear to be capitalizing any of the letters. Does it matter if the entries are both letters and numbers?

 

Thanks for your help!

 

Logan

Share this post


Link to post
Share on other sites

Hello Logan,

 

I checked with numbers also.

Please note, that you should add a Header&Footer element, select the Footer element, click the Source button (or disable HTML Editor) and enter the code. If you enter the code before the field, script cannot work.

Please also note, that the name of the field must be the exact same as in Table design.

 

Please verify, that it's a Submission form. If it's a Details or Single/Update form, you can use the following code:

<script type="text/javascript">
function capitalize()
{
var fieldname = "YOUR_FIELD_NAME";
fieldname = "EditRecord"+fieldname;
confirmname = fieldname+"@Confirm";

document.getElementById(fieldname).value = document.getElementById(fieldname).value.toUpperCase();
document.getElementById(confirmname).value = document.getElementById(confirmname).value.toUpperCase();
}
document.getElementById('caspioform').onsubmit=capitalize;
</script>

Have a nice day!

Share this post


Link to post
Share on other sites

Thanks Xiang!

 

I was able to get the script to work, but only under certain conditions.

 

First, the script only worked when I used a table as the data source for my datapage. A view data source did not allow the script to function properly. I made sure to use the exact name of the field in my view, but did not work. I then tried to change the data source to the parent table and changed the name of the field from that table and it worked. Any Idea as to why a view would not work?

 

Second, even though I was able to get it work using the parent table, it would only work in a preview, but would not work when deployed on my web page. Any suggestions?

 

Best regards,

 

Logan

Share this post


Link to post
Share on other sites

Hello Logan,

To force the letters inputted to be capitalized you can use this JavaScript code:

<script type="text/javascript">
function uppercase(field)
{
return function ()
{
field.value = field.value.toUpperCase();
}
}

var fields = document.querySelectorAll('input[type="text"][id^="InsertRecord"]');
fields.forEach(
function (field, index)
{
field.oninput = uppercase(field);
}
);
</script> 

Hope that helps.

 

Share this post


Link to post
Share on other sites
On 3/18/2016 at 11:04 PM, pilotexpressions said:

Does anyone have a script that will capitalize all letters in a submission form field? Including a confirmation field? I want the entry to be recorded in my data table in all uppercase.

 

Thanks!

 

Logan

 

Hi Logan,

What you may want to consider instead is applying the following CSS style to the input field:     text-transform: uppercase;

You can try this code in the header of the DataPage.

<style>
input {
text-transform: uppercase;
}
</style>

-Franchiser-

 

 

Share this post


Link to post
Share on other sites

Hi,

 

On a Submission Form DataPage, you may also make use of a Calculated Value element. The idea is to create a virtual field to hold the value you wanted to convert to all-caps. Then for the actual field, the syntax would be something like:

UPPER('[@cbParamVirtual1]')

 

Then, you can just hide the virtual field in a <div style="display: none"> </div> block. Here's the how-to article (Scroll over to: Using HTML Blocks to hide fields).

 

Hope this helps.

 

Regards,

DN31337

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...