I have been trying to figure out how to set a maximum number of characters that can be entered into a prompt box that appears as part of a javascript, activated by clicking a button on a PHP page. I've found lots of information on how to display an alert when too many characters are entered, but I want it to work like the maxlength attribute does for a textfield in HTML.
This is the code that I have right now:
Any help is appreciated. Thanks.
This is the code that I have right now:
Code:
function user()
{
var username=prompt("Please enter your name.","");
if (username==null || username=="" || username==" ")
{
document.getElementById('message').innerHTML="Username invalid!";
}
else
{
return username;
}
}
Any help is appreciated. Thanks.