Created
November 20, 2013 04:50
-
-
Save zakhardage/7557890 to your computer and use it in GitHub Desktop.
I needed to convert the customers 3-character input into lowercase-uppercase-lowercase (e.g. "eMc").
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="custom monogram"> | |
| <label>ADD A MONOGRAM:</label> | |
| <input type="text" onkeyup="caseChange()" id="monogram" maxlength="3" /> | |
| <p class="notes">Please enter your monogram here in the correct order: first, last, middle. Monogram may not be changed to another style or full name.</p> | |
| </div> <!-- end .custom .monogram --> | |
| <script> | |
| function caseChange() { | |
| var str = document.getElementById('monogram').value; | |
| var one = str.substring(0,1); | |
| var m1 = one.toLowerCase(); | |
| if(str.length>1) { | |
| var two = str.substring(1,2); | |
| var m2 = two.toUpperCase(); | |
| } | |
| if(str.length==3) { | |
| var thr = str.substring(2,3); | |
| var m3 = thr.toLowerCase(); | |
| document.getElementById('monogram').value = m1+m2+m3; | |
| } | |
| if(str.length==1) {document.getElementById('monogram').value = m1;} | |
| if(str.length==2) {document.getElementById('monogram').value = m1+m2;} | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment