4

Is there a way to format an alphanumeric field to convert all letters in to upper case letters automatically? The entry is for a serial number, which could start with any number or letter, I simply would like the serial number to look like the following: C02MBP46NYE instead of C02mbp46nye.

2 Answers 2

3

I'm a developer with Cognito Forms.

Yes, you can set the default value of your Text field to a calculation that targets the Text field itself and converts it to uppercase.

In the following example my Text field is labeled 'Text', and the following calculation is added to the default value.

=Text.ToUpper()

Any text entered into the Text field will be converted to upper case. You can learn more about this calculation and other text calculations in our Text Calculations Help Content.

-1

Usin jQuery you could listen for the keyup event and use the js fn toUpperCase().Will be something lke this:

$(document).ready(function(){
$(document).on('keyup', '#your-input', function(){
    var upper = $(this).val().toUpperCase();
    $(this).val(upper)
})
})

An independent approach: With php you could take the input text 'as is' and use the strtoupper() function like this:

<?php 
$text = $_GET['input_text'];
$upper = strtoupper($text);
?>
2
  • That might be fine for someone who has a custom web app of their own, but that's not happening here. Arbitrary JavaScript can't just be added to a Cognito Form, and I doubt it's built in PHP, much less allow arbitrary code to be added. Even so, this is a site for questions from users; most are not going to be open to a code solution.
    – ale
    Feb 27, 2017 at 19:40
  • That's right, didn't noticed it, my bad :( Feb 28, 2017 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.