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)); } 

simple js fiddle demo.

references:


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -