RobertTG wrote:
Someone please translate the code below into English...
Particularly the indicated line
Thanks
function attachComment()
{
var aForms = document.getElementsByTagName("FORM");
for (var i = 0; i < aForms.length; i++)
{
var oForm = aForms[i];
if (/comment_fieldset/.test(oForm.className)) // <--- WHAT DOES THIS
LINE MEAN ?
{
oForm.onsubmit = function()
{
return addComment(this);
}
}
}
}
/comment_fieldset/ is a Regular Expression Object object, and test is
one of the methods of it.
see this:
Microsoft® JScript®
test Method Language Reference
Version 3
See Also Applies To
--------------------------------------------------------------------------------
Description
Returns a Boolean value that indicates whether or not a pattern exists
in a searched string.
Syntax
rgexp.test(str)
The test method syntax has these parts:
Part Description
rgexp Required. A Regular Expression object. Can be a variable name or
a literal.
str Required. The string to test a search on.
Remarks
The test method checks to see if a pattern exists within a string and
returns true if so, and false otherwise.
The RegExp object is not modified by the test method.
The following example illustrates the use of the test method:
function TestDemo(re, s)
{
var s1;
// Test string for existence of regular expression.
if (re.test(s))
s1 = " contains ";
else
s1 = " does not contain ";
// Get text of the regular expression itself.
return(s + s1 + re.source);
}