airjohn Posted July 13, 2020 Share Posted July 13, 2020 Hello forum I have a module that uses the below code to render the register form. {assign value=$register_form.formFields var="formFields"} {foreach from=$formFields item="field"} {form_field field=$field} {/foreach} I need to insert a small javascript on some fields that does upper case during typing. Is there any way to edit the fields of the form before it is rendered? Thanks Link to comment Share on other sites More sharing options...
EvaF Posted July 14, 2020 Share Posted July 14, 2020 I would do it via css f.e. <style> .register-form input[name=lastname], .register-form input[name=firstname] { text-transform: uppercase; } </style> Link to comment Share on other sites More sharing options...
airjohn Posted July 14, 2020 Author Share Posted July 14, 2020 Hi EvaF Thanks for your response. The problem with css is that fields are not saved in capital on the database. The same question derives on the address-form.tpl, if someone wants to do uppercase and save fields in capital, what would be the solution? Link to comment Share on other sites More sharing options...
EvaF Posted July 14, 2020 Share Posted July 14, 2020 (edited) aha, I didn't realized it so do it using javascript with specific fields <script type="text/javascript"> $(document).ready(function ($){ $(".register-form input[name='lastname'], .register-form input[name='firstname']").keyup(function(){ $(this).val( $(this).val().toUpperCase() ); }); }); </script> Edited July 14, 2020 by EvaF (see edit history) Link to comment Share on other sites More sharing options...
airjohn Posted July 14, 2020 Author Share Posted July 14, 2020 Thanks EvaF! Yes it looks that it works. This is what I finally used. $(document).ready(function(){ $("input.form-control[name='firstname'], input.form-control[name='lastname']").keyup(function(){ $(this).val($(this).val().toUpperCase()); }); }); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now