How to make a specific text input field to not accept spaces?

By: Pablo Tires | Asked: 01/02/2025
ForumsCategory: General questionsHow to make a specific text input field to not accept spaces?
Pablo Tires asked 2 days ago
I have this text field where I want people register their product serial number. I have noticed a lot of my customers are entering blank spaces between the numbers. I would like to have this specific input field to not accept the empty space characters on it. Thanks a regards,  
1 Answers
Rob LeVineRob LeVine answered 2 days ago
You'll need to use jQuery. Google "jquery eliminate white space" or something similar. You'll see something like the following: $(document).ready(function() { $("#your-text-field").on("input", function() { $(this).val($(this).val().replace(/\s/g, '')); }); }); Alternatively you could let them type in spaces and remove them when the entry is submitted by using the frm_after_entry_create hook.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right