Format check
Check the format of a question.
Rule description: the Subject Initials value must be 3 characters or 2 characters with a dash in place of the middle initial. No numbers, spaces, or special characters are allowed.
Rule expression
var str=txtitem1.toUpperCase();
if(str.length==3 && (str.match("^([A-Z]){3}$") || str.match("^(([A-Z])[-]([A-Z]))$")))
{
return true;
}
else
{
return false; //System sends query if the return false condition is met
}
Query Message: Value is not recorded in the required format of 3 charactes or 2 with a dash in place of the middle initial
Definitions
- txtitem1
-
Question or Item for which you want to check the format, Subject Initials from the rule description.
- .toUpperCase()
-
JavaScript method for string objects to convert a string in all upper cases.
- .match()
-
JavaScript method for string objects to check a string value against a regular expression which returns an array of matches.
Return value
Verification steps
In the following verification steps for the given rule expression, we use <item> that refers to subject initials.
- Using a subject for testing, go to the given visit and form containing the
iems to check, in this example the subject initials
<
txtitem1
> . - Update the form item
txtitem1
as in the following table and verify the result is as listed:txtitem1
Result 'ABC' No query 'abc' No query 'AbC' No query 'A-b' No query 'A-A' No query 'a-z' No query 'A' Query 'AB' Query 'Ab' Query 'A_B' Query '123' Query 'A13' Query 'AB@' Query 'AB$' Query 'AB!' Query 'AB&' Query 'A B' Query 'Abc' No query
Note:
Repeat the above steps if the form is present in multiple visits.
Other examples
Example 4-10 The 'Kit Number:' must be 5 digits
var wk2num=KITNUM.toString();
if(wk2num.length==5)
{
return true;
}
else
{
return false;
}
Query message: Kit number does not meet the requirements (kit number must be 5 digits). Please correct or clarify.
Parent topic: Electronic Data Collection (EDC) examples