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
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.
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);
?>
-
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.– aleFeb 27, 2017 at 19:40
-