• Resolved amateria

    (@amateria)


    Three of my number input fields allow negative quantities and do weird things with decimal values. The three fields are: Total T-shirt Quantity, Total Calendar Quantity, and Donation Amount.

    Plus, and most importantly, it will pass the negative values to the Subtotal section which is terrifying even though it appears to not allow it to submit (it’s currently in Sandbox mode).

    I would like it to prevent negative numbers and decimals from being entered in the input fields or at the very least prevent the negative and weird subtotals from displaying at the bottom and allowing a negative grand total.

    I appreciate any advice or help anyone has to offer.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 23 total)
  • Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    Hi @amateria,

    I hope you are doing good, and thank you for reaching out to us.

    Could you please share an export of the form to help you with this?

    Please upload the export of the form into Google Drive or DropBox and share the URL so that we can access it. Please find how to export a from in our documentation here: https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export

    Kind Regards,
    Nebu John

    Thread Starter amateria

    (@amateria)

    Thread Starter amateria

    (@amateria)

    Any luck with this yet?

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @amateria

    I hope you are doing good today.

    I pinged our SLS and Forminator team to review this. Please note form will be not submitted with such data and this is how those fields work. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Thread Starter amateria

    (@amateria)

    Thank you for your help! It seems odd to me that anyone would ever want a payment form with fields that could be input and passed as a negative number, but it seems that both the number and the currency fields allow this. Is there maybe another field or field setting that might work? I also have all of those fields set up with a zero minimum value but it doesn’t seem to matter.
    Again, I appreciate your help and I hope this extra info is useful.

    Thank you!
    Jamie

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @amateria

    When we set the min value it gives a front end validation:

    https://monosnap.com/file/EuxIkI5l4sX4pnD3PuJhDESlzX1iG0

    Also not allowed to submit the form.

    But I do see what you mean about it allowing negatives value on the front end, even it gives the validation it should stop on 0.

    Those are reported situations and we let our developers know you are also having this issue.

    A workaround for the currency field is using this script:

    <?php
    
    add_filter( 'forminator_field_currency_markup', function( $html ){
    
    	$html = str_replace( 'type="number"', 'type="number" min="0" ', $html );
    
    	return $html;
    
    }, 20, 1 );

    You can install it as a mu-plugin following this guide https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    This is only a temporary solution that sets the HTML min attribute to currency fields.

    https://www.w3schools.com/tags/att_input_min.asp

    Best Regards
    Patrick Freitas

    Thread Starter amateria

    (@amateria)

    Thank you so much! I appreciate all of your help! Will you come back here to comment after the developers have had a chance to look at it or is that something you handle a different way?

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @amateria,

    The suggested changes of adding the mu-plugins etc would require server access. It would be better if you could get your developer to make the changes.

    If you still have any queries on how to proceed then please do let us know and we would be happy to assist you further if needed.

    Have a nice day ahead.

    Kind Regards,
    Nithin

    Thread Starter amateria

    (@amateria)

    Thank you, Nithin. Yes, I have server access and will be adding the mu-plugins today. I appreciate all of your support!

    Thank you,
    Jamie

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @amateria ,

    Let us know if you tried that mu-plugin and if that works for you.

    kind regards,
    Kasia

    Thread Starter amateria

    (@amateria)

    Hi Kasia,
    I was unable to try it yesterday but will certainly let you know as soon as I do. Thank you so much for checking in with me! ??

    Jamie

    Thread Starter amateria

    (@amateria)

    Okay, I tried it and nothing seemed to change. I have uploaded a current version of the form code here:
    https://drive.google.com/file/d/17CbaGOYQStKI0tRozWPeOUQEi-dFHlxb/view?usp=sharing

    And here is a screen shot of how I have it in FileZilla:
    https://astronomyclub.org/nhacwp/currencycorrector.pdf

    Any ideas?

    Thank you!
    Jamie

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @amateria

    I hope you’re well today!

    I’ve downloaded your form and put it on my test site and then added the code that was shared with you. I’ve tested it and it works as expected on my end – it makes it impossible to go to negative values.

    If it doesn’t work on your end then there are two most probable reasons for this:

    – either there’s some other/additional conflict
    – or the code was not applied correctly after all

    I’d start with the second option.

    I understand that the code is in negativeerrorsnippet.php file. Location of this file seems correct so could you also share a screenshot (exactly as it is in the file) of the code in the file?

    Are you absolutely sure also that it’s actually added to correct WP installation? I know it sounds a bit strange but it’s not uncommon if there are more installs on a single server/hosting accounts so I just want to make sure…

    Best regards,
    Adam

    Thread Starter amateria

    (@amateria)

    Hi!
    I’m not 100% clear about what you did. In my last post I linked to the file I exported of the form that had the new snippet of code already in place. Or at least it should have. Was that not a helpful file? Is there a better one I could link to?

    Actually the snippet is in the currencycorrector.php file. I will send a link to a screenshot of that code in my next post.

    Also, yeah, I only have the one WP installation. :/

    Thank you, Adam!

    Thread Starter amateria

    (@amateria)

    Here is the snippet that shows how I saved and uploaded it:

    https://astronomyclub.org/nhacwp/CurrencyCorrectorCodeScreenCap.pdf

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘Negative Value and Number Issues in Number Input Field’ is closed to new replies.