SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    May 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery live typing

    I have this code:
    Code:
    <html>
    <head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    
        $('div[contenteditable]').focus();
        $('div[contenteditable]').keypress(function (e) {
    	
        if(e.which == 13)
    	
        {
           document.location='http://www.' + $('div[contenteditable]').html() + '.com';
        } 
        });
    
    });
    </script>
    <style>
    div[contenteditable] { background:white; font-size:42px; color:black;outline:none; border:none; }
    </style>
    </head>
    <body>
    <div contenteditable></div>
    </body>
    </html>
    and I want to add several conditions like : only two words to be accepted, for example google and yahoo also if is nothing typed in and the return(enter) is pressed to appear a alert or something like this...
    Thanks...

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    If you wish to allow only two words to be 'entered' in the field, simply make it a DROPDOWN with those two choices.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Member
    Join Date
    May 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the problem, I don't want to make a dropdown, I want to make conditions, for example when a user type everything else than google or yahoo to appear an alert


Tags for this Thread

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
  •