www.webdeveloper.com
Results 1 to 4 of 4

Thread: accepting both upper and lower case lettes in an input box

  1. #1
    Join Date
    Jan 2014
    Posts
    1

    accepting both upper and lower case lettes in an input box

    I have this code but I need to be able to input either lower case or upper case and get a result. For example I want to enter history and get back History Book and also enter HISTORY and get back History Book.

    I there a way I can do this.


    Here is my code.
    <html>
    <head>
    <title>Untitled</title>
    <script type="text/javascript">
    <!--
    function show_prompt()

    {
    var book=prompt("Enter a book");



    if(book == "history" ){
    document.write("<b>History Book</b>");
    }else if( book == "maths" ){
    document.write("<b>Maths Book</b>");
    }else if( book == "economics" ){
    document.write("<b>Economics Book</b>");
    }else{
    document.write("<b>Unknown Book</b>");
    }
    }

    //-->
    </script>
    </head>

    <body>



    <input type="button" onclick="show_prompt()" value="click here to find out the book you need" />
    </body>
    </html>

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,270
    There is two method toLowerCase() and toUpperCase() to change String...
    HTML Code:
    var book=prompt("Enter a book");
    var bookLwr=book.toLowerCase();

  3. #3
    Join Date
    Jan 2014
    Location
    USA
    Posts
    37
    Hello Pearl89,

    strtoupper and strtolower

    help to get rid out of thisd

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,653
    brilliant!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles