Difference between revisions of "Validate email specified as an open text of a single question"
m (→Solution) |
m (→Challenge) |
||
Line 3: | Line 3: | ||
As a CGS writer <br/> | As a CGS writer <br/> | ||
I want to validate an email specified as an open text of a single question<br/> | I want to validate an email specified as an open text of a single question<br/> | ||
+ | <br/> | ||
Example<br/> | Example<br/> | ||
+ | <br/> | ||
[[Image:Validate_email_-_semi_open_question.png]] | [[Image:Validate_email_-_semi_open_question.png]] | ||
+ | |||
==Solution== | ==Solution== | ||
<source lang=javascript> | <source lang=javascript> |
Revision as of 04:04, 17 November 2009
Challenge
In order to secure my questionnaire's input
As a CGS writer
I want to validate an email specified as an open text of a single question
Example
Solution
var qLabel = "Q1";//question's label
var openAnswerValue = 1;//the value of answer option which has open text
var ErrorMessage_InvalidEmail = "Invalid email.";//error message in your needed language
var oldQuestionCheck = this.questioncheck;
questioncheck = function()
{
if (!oldQuestionCheck())
return false;
var email = $("input[name='QUESTION." + qLabel + ".Open." + openAnswerValue +"']").val();
if (!validateEmail(email))
{
ErrorMessages.getInstance().showErrorMessage(ErrorMessage_InvalidEmail);
return false;
}
return true;
}