SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    Cleveland, TN
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.prompt length?

    Is there a way to set a max length on a window.prompt? I want to limit the number of characters to 50 that a user can enter. This is the code I am using to get the prompt:

    var newName = window.prompt('What do you want to name this Content Version?', contentName);
    //if they click cancel or enter an empty string, exit the function
    if ((newName == null) || (newName == '')){
    return;
    }

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2003
    Location
    Cleveland, TN
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I figured it out. I added the following:

    if (newName.length > 50){
    alert('Please enter a shorter name');
    return;

    and it seems to be working


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •