validation - validate iput in jquery in specific code structure -



validation - validate iput in jquery in specific code structure -

hello i'm @ coding form , have validate jquery , php need in phone input digit usable , min of 6 numbers must appear . in jquery code construction :

if ($('input[name="phone"]' ).val().length ===0){ erros = 1; } else { $('input[name="phone"]').removeclass('warning'); }

here phone input code :

<label class="label">phone number</label> <label class="input"> <i class="icon-append fa fa-phone"></i> <input type="text" name="phone" id="phone" > </label>

how base of operations jquery validation on needs ? in advance

i updated script , made somehow validate digit input cant go foward until 10 numbers typet on phone input box here code :

var phoneval=$('input[name="phone"]').val(); phoneantigo = phoneval.tostring(); var phonereg = /\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})$/; if ($('input[name="phone"]').val().length === 0) { erros = 1;} else if(!phonereg.test(phoneval)) { $('input[name="phone"]').val(''); erros = 1; } else { $('input[name="phone"]').removeclass('warning');}//end of test

$('#phone').on('input', function (event) { $this.val() = $this.val().replace(/[^0-9]/g, ''); // allow numeric characters if ($this.length < 6){ // if less 6 characters, add together warning class erros = 1; $this.addclass('warning'); } else { $this.removeclass('warning'); } });

jquery validation

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -