lundi 18 juin 2018

javascript validation in textfield

instantly alert when user break validation, but here which script in 1 problem, when i click input textfield than alert msg even i didn't enter any value.

<script>
        function validation(){
            var rate = document.getElementById("rate").value;
            if (rate == "" || rate.length<5);
            alert("it is wrong value");
            return false;
        }
    </script>
<div class="form-group col-lg-5">
                {!! Form::label('rate', 'Traded Rate:') !!}
                {!! Form::text('rate', null, ['class'=>'form-control', 'onclick'=>'return validation()'])!!}
            </div>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire