Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Textinput To Lower/Upper Case?

In a game for school, I want the player to be able to enter answers into a textinput field. However, I don't want capitalization to be a factor.

How can I go about parsing the variable to upper/lower case?

Right now, I have this in the stylesheet:
input {
text-transform: uppercase;
}
That makes the text the player enters in the field appear in all uppercase, but the actual variable is whatever case the user inputted.

I understand this is the JavaScript needed:
$('input').keyup(function(){
this.value = this.value.toLowerCase();
});
However, I don't know how to use that to change the variable's value. I'm an idiot, I know. ;D

Thanks!

Comments

  • The keyup function is assuming you have an event listener for keys, which you don't need if you're using the inputtext macro in Twine. Just convert the text to lowercase in the existing textinput macro.

    So do it like this. At the very start of the macro find the params argument and convert that first thing.
    params[0] = params[0].toLowerCase();
    If you need help I might pop on irc later.
  • I don't recommend editing the built-in macros, simply for practicality reasons.

    I do recommend using .toLowerCase() for the actual variables:
    <<set $answer to $answer.toLowerCase()>>
Sign In or Register to comment.