Input type number teased

0

I come to you with a slightly easy question to see who can answer me.

I have a normal input type number with its two arrows to increase and to decrease limited to a minimum of 1 and a maximum of one hundred;

    <input
    type="number"
    min="1"
    max="100" value="{{ $item->quantity }}" id="product_{{ $item->id }}"
    >
        <a 
        href="#" 
        class="btn btn-warning btn-update-item"
        data-href="{{ route('cart-update', $item->slug) }}"
        data-id = "{{ $item->id }}">
                    <i class="fa fa-refresh"></i>
        </a>

The problem was after someone simply placed the cursor inside the input and started writing letters and numbers; then I get a lot of errors with the letters and with the numbers does not leave any error, but then it does not let me advance in other functions to have more than the maximum number.

Is there a way that no user can edit this line in a forced way?

    
asked by basosneo 10.03.2017 в 06:44
source

2 answers

3

Short answer: no, it is impossible to guarantee what you ask .

Think that the user has thousand and one ways to skip what you intend. From using old browsers, to the same query using external tools, as wget . Going through, simply, open the source code of the page, edit the field, and eliminate any possible limitation that exists.

Summing up: Never , Never from never , Under any reason or circumstance , trust that you will receive exactly what you want to receive. Check the validity of the data ALWAYS .

This is a golden rule in any language, program or technology. Program always on the defensive, as if the user will try by all means within their reach break your program.

    
answered by 10.03.2017 в 06:56
0

If friends were possible, using a javascript function

  

if (quantity < 1 || quantity > 100) {           // show some error using jquery

      var message ='Solo Numeros y No mayor a cien';
        alert(message);
        return true;

     }

I'm surprised that no one here has been able to answer this question.

In general nobody answers my questions, but something as easy as this leaves me surprised in a bad way.

Thanks for your comments! Greetings!

    
answered by 11.03.2017 в 13:57