jquery - check for spacing or - in a text filed -
i'm trying check empty spacing or - character in textfield. can use -
function isvalid( str ){    var is_valid = true;   if(str.indexof('-') === -1){      is_valid = false;   }   return is_valid; } but want combine method checks multiple - , empty spacing between characters.
example enter string this. var str = "emp t y" want check if empty space present or if this. var str = "12-34-55"
i'd suggest:
function isvalid( str ){     return !(/-|\s/.test(str)); } references:
Comments
Post a Comment