Friday, 23 August 2013

check for spacing or - in a text filed

check for spacing or - in a text filed

I'm trying to do a check for empty spacing or - character in a textfield.
I can use this for -
function isValid( str ){
var is_valid = true;
if(str.indexOf('-') === -1){
is_valid = false;
}
return is_valid;
}
but I want to combine a method that checks for multiple - and empty
spacing between characters.
Example someone could enter a string like this. var str = "emp t y" I want
to check if the empty space are present or if they do something like this.
var str = "12-34-55"

No comments:

Post a Comment