• Resolved fimo66

    (@fimo66)


    Hi,
    I have seen several times on my site that users by a mistake uses 2 digit as a guess on the result on a match so ie 1-2 becomes 12-2, know its a human mistake but was thinking if i as a admin can change the fields where users make their guess to only allow one digit and not 2 as i think it is today ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author AntoineH

    (@antoineh)

    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

    Plugin Author AntoineH

    (@antoineh)

    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…

    Plugin Author AntoineH

    (@antoineh)

    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.

    Thread Starter fimo66

    (@fimo66)

    Thanks ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘one digit guess ?’ is closed to new replies.