Jump to content

input length


verN

Recommended Posts

yes write a simple javascript function that checks the input field length and outputs an error or does nothing at all


<input id="name" type="text" name="name" onChange="checkInput()">

function checkInput()
{
var str = document.getElementById("name").value;
if ( str.Length > 20 )
{
alert("Please enter less than 20 characters");
}
}

Link to comment
https://forums.phpfreaks.com/topic/46685-input-length/#findComment-227445
Share on other sites

Good idea rallokkcaz, that will work but wont throw the error requested

 

if its more then a error is outputted.

 

but both will work. one just prevents more than 20 the other one allows it but warns if you do, I suppose it comes down to information about the text box being available on the site to say that you are only allowed 20 characters etc.

Link to comment
https://forums.phpfreaks.com/topic/46685-input-length/#findComment-228615
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.