subscribe

Careers

subscribe

Careers

Greetings

ShowIt Forms: scripts to disable new lines and format capitalisation in inputs

Sharing two scripts I wrote in order to improve input uptake for forms created on ShowIt.

Add these scripts on any page where you have created ShowIt forms (in the Advanced panel, under “Page Loaded Javascript”).

The first script below makes certain the user cannot go to a new line when pressing the return/enter key. This is particularly useful for single-line inputs, like names and emails (otherwise, if the go to a new line, then the first line disappears from the user’s view, potentially creating confusion).

//DISABLES NEW LINE IN TEXT AREA

var textAreas = document.getElementsByTagName('textarea');

for (var i = 0; i < textAreas.length; i++) {
  textAreas[i].addEventListener('keypress', function (e) {
    if (e.keyCode === 13 || e.which === 13) {
      e.preventDefault();
      return false;
    }
  });
}

The second script converts input into title case (lowercases the entire input and then capitalises the first letter). This is helpful for several reasons, including for building a tidy email list where first names are all capitalised.

Note that even if you format the showit textbox in title case, the saved input will have the original name as it was it was typed by the user, unless you use this script (therefore, this converts “aNdreas” to “Andreas”).

// CONVERTS INPUT INTO TITLECASE

var textAreas = document.getElementsByTagName('textarea');

for (var i = 0; i < textAreas.length; i++) {
  textAreas[i].addEventListener("input", function() {
    var inputValue = this.value;
    var lowercaseValue = inputValue.toLowerCase();
    var titleCaseValue = lowercaseValue.charAt(0).toUpperCase() + lowercaseValue.slice(1);

    // Update the textarea value with the title case text
    this.value = titleCaseValue;
  });
}
Subscribe →

digest

Get the

Subscribe for updates on articles like this (bi-weekly digest)

Leave a Reply

The Latest posts

Popular reads in the magazine

Andreas

travel the globe photographing life’s important events, weddings, and editorial shoots.

more about Andreas →

PHOTOGRAPHER, WRITER,  GENTLEMAN

welcome, I 'm

I

The AKG studio was created out of my fascination for blending modern techniques with the art d'excellence from a bygone era, creating a photography of timeless aesthetic and heritage. 

My photography is intimate and infused with a sense of purpose, stemming from a deep desire to advocate for diversity, empathy and empowerment.

you

Photography as extraordinary as

Images as remarkable as you.

Get a month free of showit

With my friends at ShowIt, we are offering a month free of ShowIt.

HINT: This entire website is built on ShowIt, and I couldn't recommend it more!

Stay ahead of the curve 
with the latest educational content: workshops around the world, articles, free e-books & podcasts
A FREE email course about shipping your Art to the world. It's for ALL Wedding Artists (regardless of specialty)
The missing intro to Modern Marketing for Artists

Learn more

Enroll now - it's free
 - Subscribe for exclusive updates -

extraordinary

Keep your


Stay ahead of the curve

With the latest educational content - Workshops around the world, articles, podcasts.