title: Restrict input in a Prompt box
body: <p>I want my prompt box to take a maximum input of 10 characters.If the user presses any key after that no text should be entered.</p>
  
  <p>Currently the code i am using uses while condition to check whether the input is within limit.If it is beyond limit it accepts the text but keeps prompting the user until the input is within limit.The value will be assigned to person1 variable and the code will proceed forward only when input is within limit. </p>
  
  <p>I want the input box not to accept more than specified input in the 1st place itself..</p>
  
  <p>Please help. </p>
  
  <p>The code is as follows:</p>
  
  <pre><code>      person1=prompt("Please enter your data 1(Maximum limit 20)","Sample 1");
        while(person1.length &gt; 20){
           alert("Keep the message length to 20 chars or less")
           person1 = prompt("Please enter your data 1(Maximum limit 20)","Sample 1");
          }
  </code></pre>