Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Open end validation

I am designing a opening  which should allow at least 3 words in it .
asked Oct 20, 2015 by sandeepkapalawai Bronze (1,475 points)
retagged Oct 20, 2015 by Walter Williams

1 Answer

0 votes
var x = $("#A1b").val();
var cnt = x.trim().split(/\s+/).length;
var res = x.split(/\s+/);
var i=0;
var letters = /^^[\\.`,{}*:;"'~!@#$%\[\]|^&*()_+\-=\/?><]+[\\.`{},*:;"'~!@#$%\[\]\s|^&*()_+\-=\/?><]*$/;
if( cnt < 3 )
{
strErrorMessage = "Your response must contain at least 3 words.";
}
else
{
for(i=0;i<=cnt;i++)
{
   
   if(res[i].match(letters))
    {
            strErrorMessage = "please provide a valid response.";
            break;
    }
    else
    {
        strErrorMessage = "";
    }
}
   
}
answered Oct 20, 2015 by Harika Mandula
...