Open In App

script.aculo.us Autocompleter.Local ignoreCase Option

Last Updated : 20 Nov, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The script.aculo.us library is a cross-browser library and the aim is to improve the user interface of a website. The Autocompleter can be used for providing auto-completion support for text fields in the webpage. The local Autocompleter is used when auto-completion options are given as an array to the Autocompleter method to display as the choices.

The Autocompleter.Local ignoreCase option is used to tell whether to ignore the case of the search text while autocompleting.

Syntax:

{ ignoreCase: boolean }

Values:

  • boolean: This is a boolean value that specifies whether the case is ignored in the search text. The default value is true.

Example 1: In this example, we have set the ignoreCase option to false, therefore the case of the text is not ignored while autocompleting.

HTML




<!DOCTYPE html>
<html>
  
<head>
  
    <!-- Include the required scripts -->
    <script type="text/javascript" 
        src="prototype.js">
    </script>
  
    <script type="text/javascript" 
src="scriptaculous.js?load = effects,controls">
    </script>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <label for="GeeksforGeeks">
        Input any name:
    </label>
      
    <br />
    <input id="GeeksforGeeks" autocomplete="off" 
        size="40" type="text" value="" />
  
    <div class="autocomplete" id="names" 
        style="display:none">
    </div>
  
    <script type="text/javascript">
  
        // Array to be used as choices
        var names = [
            'Ab',
            'Abc',
            'Abcd',
            'Abcde',
            'Abcdef',
            'Abcdefg',
            'Abcdefgh'
        ];
  
        // Initialize the Autocompleter
        new Autocompleter.Local('GeeksforGeeks',
            'names', names, {
  
            // Do not ignore the case 
            // while autocompleting
            ignoreCase: false
        });
    </script>
</body>
  
</html>


Output:

Example 2: In this example, we have to set the ignoreCase option to true, therefore the case of the text is ignored while autocompleting.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <!-- Include the required scripts -->
    <script type="text/javascript" 
        src="prototype.js">
    </script>
  
    <script type="text/javascript" 
src="scriptaculous.js?load = effects,controls">
    </script>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <label for="GeeksforGeeks">
        Input any name:
    </label>
      
    <br />
    <input id="GeeksforGeeks" autocomplete="off"
        size="40" type="text" value="" />
  
    <div class="autocomplete" id="names" 
        style="display:none">
    </div>
  
    <script type="text/javascript">
  
        // Array to be used as choices
        var names = [
            'Ab',
            'Abc',
            'Abcd',
            'Abcde',
            'Abcdef',
            'Abcdefg',
            'Abcdefgh'
        ];
  
        // Initialize the Autocompleter
        new Autocompleter.Local('GeeksforGeeks',
            'names', names, {
  
            // Ignore the case while
            // autocompleting
            ignoreCase: true
        });
    </script>
</body>
  
</html>


Output:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads