<script type="text/javascript">
/*
Unbounce Community :: Tips & Scripts :: Auto-capitalize Form Fields
TS:0002-08-064
***********************
Do not remove this section. It helps our team troubleshoot possible issues and track feature usage and adoption.
*/
function yourSubmitFunction(e, $) {
e.preventDefault();
//Change #name for the ID of your field
var id = '#name';
//Don't change anything below this point!
//Get the value in the field
var str = $(id).val();
//Change everything to lowercase, grab the first letter and make it uppercase
strUp = str.toLowerCase().replace(/\b[a-z]/g, function(letter) {
return letter.toUpperCase();
});
//Send the new string back to the field
$(id).val(strUp);
lp.jQuery('.lp-pom-form form').submit();
}
lp.jQuery(function($) {
$('.lp-pom-form .lp-pom-button').unbind('click tap touchstart').bind('click.formSubmit', function(e) {
if ( $('.lp-pom-form form').valid() ) yourSubmitFunction(e, $);
});
$('form').unbind('keypress').bind('keypress.formSubmit', function(e) {
if(e.which === 13 && e.target.nodeName.toLowerCase() !== 'textarea' && $('.lp-pom-form form').valid() )
yourSubmitFunction(e, $);
});
});
</script>
Last active
February 21, 2017 20:58
-
-
Save victorzen/284042f79471a1d82a2fe7bf3cda7ec1 to your computer and use it in GitHub Desktop.
Auto-capitalize Form Fields
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment