views:

87

answers:

2

How to check for comma separated values in a text box and raise an alert if not found. And there is should be characters in it like A,B,C,D

  function validate()
   {
         //validate text box;
   }
  <input type="text" id="val" >A,B,C,D</input>
  <input type="button" id="save" onclick="validate()">  

Thanks.

+2  A: 
/^[A-Za-z](?:,[A-Za-z])*$/.test(document.getElementById("val").value)
Matthew Flaschen
A: 

I hope this will help you

`function validate() {

val = document.getElementById('val').value;
val = val.split(',');
alert(val[0].length);
for(var i=0;i<val.length;i++)
{
    if(val[i].length != 1){
        alert("Please check value should be coma seperated at every single characters");
        return false;
    }

}
return true; 

}

ravindrakhokharia