Forked from RakibSiddiquee/create_input_slug_initial.html
Created
April 15, 2017 07:07
-
-
Save shahali007/cc038791f30692c92521d82c2315c589 to your computer and use it in GitHub Desktop.
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
| <!DOCTYPE HTML> | |
| <html lang="en-US"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title></title> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> | |
| </head> | |
| <body> | |
| <form action=""> | |
| Name: <input type="text" name="name" id="name"/><br/> | |
| Slug: <input type="text" name="slug" id="slug" /><br /> | |
| Initial: <input type="text" name="initial" id="initial" /> | |
| </form> | |
| <script type="text/javascript"> | |
| $("#name").blur(function(){ // Create Author name slug and initial | |
| var str = this.value; | |
| $("#slug").val(str.trim().toLowerCase().replace(/ /g,'-').replace(/ /g,'-').replace(/[^\w-]+/g,'-')); | |
| $("#initial").val(str.match(/\b\w/g).join('').toUpperCase()); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment