Hi, I need to restrict the amount of character input to 300 in a contact form

I am very new to coding with wix but I am up for anything.! In the contact form I am adding a paragraph field but I want to restrict the maximum characters client’s can input to “300”
Thanks in advance for the help!

Hello mini-“admin” :grin:,

ok first at all i will help you, but next time you should have some code, so i can see that you already tried to do something and not just desire code 4 free :wink:.

Well there are several options to achieve your problem.

What are the facts?

  • have a TEXT with more than 300-chracters, which you want to limit to exactly 300-characters.

A possible tecnique could be the “slice”-method.
https://www.w3schools.com/jsref/jsref_slice_array.asp

array .slice( start , end )

var myStringArray = ["Here you have your Text (String-Element) with more than 300-characters, for example. You will cut it when the length of 300-characters is arrived. I do not now how much characters has this example-text here, but we will restrict it to only 100-characters. I hofe everything will work like a charm xDDDDDDD"];

var myResultArray = myStringArray.slice(0,100);

console.log(myResultArray)

Of course you have to put this into the “onReady”-function, or start it with a “button”-press, to see whats happening.

My bad this will not work.
So then we will try another method :grin:, example coming soon…

Ok, here we have a little example…
https://russian-dima.wixsite.com/meinewebsite/blank-17

Hi Dima! haha thanks for the nick name :sweat_smile:

well, I have tried to search in the forums and ofc in almighty google, but I am not a website developer and my boss has tasked me with making his site.
Since I am not a coder (wish I was several time in my live) and reading at many comments I realized that limiting the character is not something build-in on Wix, and that my best chances were by using Corvid. Hence my wish for a code.

In the picture above the “At a high level, what challenge are you looking to solve?” is the title indicating what the client needs to reply on, their answers cannot be more than 300 characters so the limitation for input I need is on the answer part of the form that right now (i think) looks like this


// For full API documentation, including code examples, visit Velo API Reference - Wix.com

$w.onReady( function () {
//TODO: write your page related code here…
$w( ‘#columnStrip6’ )
});

I know it’s a lot to ask but if you could baby-step help me with the code that would be magical

Thanks!

Ohh, ok you want to limit the “input-characters”, ok now i understand (hopefully) xD. Ok therefore you will not need to code.

You have that option directly in the input-field.
Take a look at this pictures…


Look at the MOUSE-CURSOR.

Oh, I think I will have to code it because see


How about something simple like

Or something like that :rofl:

Ohhh ok, you use Wix-Forms. I have to take a look, which possibilities are given for this…

Ok, then take a look at this…

$w.onReady(function () {
    $w('#textBox1').onKeyPress(()=>{
 if ($w('#textBox1').value.length >= 20){console.log("!!!ATTENTION !!!")}
    })
});

This should help you. This will show in your CONSOLE a message (“Attention”) when you types in more than 20-character into your INPUT.

Modify it to fit it to your form.

Hi Dima, thanks! I tried other ways but the easiest was to add an input text inside the contact form! Thanks!!

You are welcome.
The main thing is that the problem is solved :grin: