Monday, July 6, 2020

Name validation check with alpha numeric using jQuery.

<div class="row">
        <div class="col-md-6 offset-md-3">
          <input type="textclass="form-control
placeholder="Full Namename="customer_name
id="customer_nameautocomplete="offrequired>
        </div>
      </div>


<script>
$('#customer_name').keypress(function(e) {
        var keyCode = e.keyCode || e.which;
        //Regex for Valid Characters i.e. 
Alphabets and Numbers.
        var regex = /^[A-Za-z0-9]+$/;

        //Validate TextBox value against the Regex.
var isValid = regex.test(String.fromCharCode(keyCode));
        if (!isValid) {
          return false;

        }

        return isValid;

      });

</script>

No comments:

Post a Comment

colourful pyramid using PHP

  <! DOCTYPE html > < html lang = "en" > < head >   < title >Colorfull Pyramid</ title >   < me...

Clock