0

I have this function to check whether the input have number and letter.

$(document).ready(function(){
    $("#submit").click(function(){
        var newtext = $.trim($('#inputtext').val());
        if newtext(condition here){
            alert("Should contain at least one letter and number");
        }
    });
})

How can I check if the input value consist of combination of letters and numbers?

Tried this and works!

if(/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/.test(newtext) == false) {
            alert ("Should contain at least one letter and number.");
}
c.k
  • 1,075
  • 1
  • 18
  • 35

0 Answers0