There are hooks that allow you to override the form in PHP. You can output an input field that only allows 1 char.
Other option is to insert some javascript in the front-end that changes the maxlength of each input. In its simplest form, this looks like this*:
jQuery(document).ready(function() {
jQuery('input.prediction').attr('maxlength','1');
});
* not tested
Seems like number inputs ignore the maxlength property, so if you have this option enabled, then the above script is not enough. But luckily we can tweak it a bit:
jQuery(document).ready(function() {
jQuery('input.prediction').attr('maxlength','1');
jQuery(document).on('input','input[type=number].prediction', function() {
this.value = this.value.slice(0,this.maxLength);
});
});
Thread Starter
fimo66
(@fimo66)
Thanks for the answer,
…..”insert some javascript in the front-end that changes the maxlength of each input,
jQuery(document).ready(function() {
jQuery('input.prediction').attr('maxlength','1');
jQuery(document).on('input','input[type=number].prediction', function() {
this.value = this.value.slice(0,this.maxLength);
});
});
Stupid question, but the above code you helped me with, where do i insert that ?
Is it a part of a larger code or is this the code to have a single digit and if so where should i insert this piece of code, any of the Football Pool files ?
Again sorry for my lack of knowledge in the coding part…
You can use a plugin like Scripts n Styles, Woody code snippets or any other plugin that helps you to insert extra javascript code in your website. If you use such a plugin then you should insert the javascript near the closing body tag.
This code snippet is all you need.