enltr xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/terms/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#"http://www.w3.org/1999/xhtml/vocab/////////////////Find repetition of characters with .repetition() | BitsyCodehttps://www.bitsycode.com/methods/forms/repetitionFind repetition of characters with .repetition() | BitsyCode Find repetition of characters with .repetition() | BitsyCode html not-front not-logged-in no-sidebars page-node page-node- page-node-27 node-type-page

Find repetition of characters with .repetition()

container

.repetition()


Description: Validate if a field contains a character that is repeated consecutively more than allowed times.


Example:

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>repetition demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
        
        <table cellpadding="10" cellspacing="0" class="blocks">
            <tr>
                <td width="100" valign="top"><b>Repetition:</b></td>
                <td>
                    <input type="text" name="repetition_field" class="repetition_field" value="BitsyCooode" />
                    <span class="repetition_field_result"></span>
                </td>
            </tr>
            <tr>
                <td></td>
                <td><input type="button" name="submit" onclick="repetition();" value="Validate" /></td>
            </tr>
        </table>
        
        <p><strong>Preview (Multiple Elements):</strong></p>
        <table cellpadding="10" cellspacing="0" class="blocks">
            <tr>
                <td width="100" valign="top"><b>Repetition:</b></td>
                <td>
                    <input type="text" name="repetition_field_1" class="repetition_field_1" value="BitsyCooode" />
                    <span class="repetition_field_1_result"></span>
                </td>
            </tr>
            <tr>
                <td width="100" valign="top"><b>Repetition:</b></td>
                <td>
                    <input type="text" name="repetition_field_2" class="repetition_field_2" value="BitsyCoode" />
                    <span class="repetition_field_2_result"></span>
                </td>
            </tr>        
            <tr>
                <td></td>
                <td><input type="button" name="submit" onclick="repetitionboth();" value="Validate Both Fields" /></td>
            </tr>
        </table>        
        
        <script>
            
            function repetition() {
                
                var repeated = bitsyCode(".repetition_field").repetition({ min:2 });
                repeated = repeated ? "&#x2718 Repetition <b>found</b>." : "&#x2714; <b>No</b> repetition.";
                bitsyCode(".repetition_field_result").html(repeated);
                
            }
            
            function repetitionboth(){
                
                var repeated = bitsyCode(".repetition_field_1, .repetition_field_2").repetition({ min:2 });
                
                rep1 = repeated[0] ? "&#x2718 Repetition <b>found</b>." : "&#x2714; <b>No</b> repetition.";
                rep2 = repeated[1] ? "&#x2718 Repetition <b>found</b>." : "&#x2714; <b>No</b> repetition.";
                
                bitsyCode(".repetition_field_1_result").html(rep1);
                bitsyCode(".repetition_field_2_result").html(rep2);
               
            }
            
        </script>
     
    </body>
    </html>

Preview:

Repetition:

Preview (Multiple Elements):

Repetition:
Repetition:
Share

Developed and built with passion and commitment.
Maintained by the bitsycode team.