Created
August 25, 2017 14:07
-
-
Save NickDeckerDevs/b4bbcd88e5fdf4f791a421a7069d74e3 to your computer and use it in GitHub Desktop.
bad bad bad bad idea to do this
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
| /* | |
| * Calls fix if user input is all lower case. This prevents changes from | |
| * happening if the user's name has different case changes like leFlour | |
| */ | |
| function check_name(input) { | |
| if(input == input.toLowerCase()) { | |
| return fix_name(input); | |
| } | |
| return input; | |
| } | |
| /* changes first letter to uppercase */ | |
| function fix_name(name) { | |
| return name.charAt(0).toUpperCase() + name.slice(1); | |
| } | |
| function sanitize_the_names() { | |
| var first_name = $('.hs-input[name="firstname"]') | |
| var proper_first_name = check_name(first_name.val()); | |
| first_name.val(proper_first_name); | |
| var last_name = $('.hs-input[name="lastname"]') | |
| var proper_last_name = check_name(last_name.val()); | |
| last_name.val(proper_last_name); | |
| } | |
| $(window).load(function() { | |
| if($('.hs-input').length) { | |
| $('.hs-input[name="phone"]').mask('(000) 000-0000'); // see https://igorescobar.github.io/jQuery-Mask-Plugin/ | |
| $('.hs_submit').append('<input type="button" id="dothis">') | |
| $('body').on('click', 'input[type="submit"]', function() { | |
| console.log('sanitaizing names and such'); | |
| sanitize_the_names(); | |
| debugger; | |
| return true; | |
| }) | |
| } | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment