1

What I'm trying to do seems simple to me, so please do excuse me if it is a stupid question, but is there any way to put a character limit on aa javascript prompt box?

Edit, I failed, I meant prompt box. Silly me.

Doge
  • 347
  • 1
  • 4
  • 13
  • Can you explain your case a little more? Do you mean an alert box or a dialogue (where a user can enter text)? If you are causing the alert box to pop up with text, can you limit your input from that side? – aaron-bond Jan 27 '14 at 12:03
  • possible duplicate of [How many characters allowed in an alert box - javascript](http://stackoverflow.com/questions/6864533/how-many-characters-allowed-in-an-alert-box-javascript) – cubitouch Jan 27 '14 at 12:05
  • Oops, I meant prompt box, haha fail on my part – Doge Jan 27 '14 at 12:09

1 Answers1

3

You might mean a prompt box, but I'll just make this answer relevant to an alert box.

Try:

alert('Text goes here'.substr(0, limit));
Sharikul Islam
  • 319
  • 2
  • 8