Tuesday, September 20, 2016

How to check a value exists in javascript array

Lets say user send a input "abcd" or "123". Now i want to check that incoming input should be  valid as assign in javascript array.

Like this -:



And you want output like this



var validFormatsArray = ['varchar','email','int','phone','sudhir'];
var isValidFormat = $.inArray('int'.toLowerCase(), validFormatsArray);

if(isValidFormat == -1){
  alert('Invalid format detected');
}else{
  alert('valid format');
}

Checkout this video tutorial







Also Read-:

Top most 15 haunted places in india which will dread your body



No comments:

Post a Comment