Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning JavaScript 4th Edition
This is the forum to discuss the Wrox book Beginning JavaScript, 4th Edition by Paul Wilton, Jeremy McPeak; ISBN: 978-0-470-52593-7
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 4th Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 9th, 2011, 09:38 PM
Authorized User
Points: 222, Level: 4
Points: 222, Level: 4 Points: 222, Level: 4 Points: 222, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2007
Location: Phoenix, AZ, USA.
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default Control names not recognized

Hi,

I'm working the Regular Expression Tester exercise in chapter 9. I believe I have the code entered correctly, but the functions are not recognizing the text fields.
<code>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Regular Expression Tester</title>
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
</style>

<script type="text/javascript">
function getRegExpFlags()
{
var regExpFlags = "";
if ( document.form1.chkGlobal.checked )
{
regExpFlags = "g";
}

if ( document.form1.chkCaseInsensitive.checked )
{
regExpFlags = "i";
}

if ( document.form1.chkMultiline.checked )
{
regExpFlags = "m";
}

return regExpFlags;
}

function doTest()
{
var testRegExp = new RegExp(document.form1.txtRegularExpression.value,
getRegExpFlags());
if ( testRegExp.text(document.form1.txtTestString.value ) )
{
document.form1.txtTestResult.value = "Match Found";
}
else
{
document.form1.txtTestResult.value = "Match NOT Found";
}
}

function findMatches()
{
var testRegExp = new RegExp(document.form1.txtRegularExpression.value,
getRegExpFlags());
var myTestString = new String(document.form1.txtTestString.value);
var mymatchArray = myTestString.match(testRegExp);

document.form1.txtTestResult.value = matchArray.join('\n');
}
</script>
</head>
<body>
<form id="form1" method="post" action="">
<p>
Regular Expression:<br />
<label>
<input name="txtRegularExpression" type="text" id="txtRegularExpression"
size="100px" value="" />
Global
<input name="chkGlobal" type="checkbox" id="chkGlobal" value="true" />
</label>

Case Insensitive
<label>
<input name="chkCaseInsensitve" type="checkbox" id="chkCaseInsensitive"
value="true" />
</label>

MultiLine
<label>
<input name="chkMultiline" type="checkbox" id="chkMultiline" value="true" />
</label>
</p>
<p>
<label>
Test Text:<br />
<textarea name="txtTestString" id="txtTestString" cols="100"
rows="8"></textarea>
</label>
</p>
<p>Result:<br />
<textarea name="txtTestResult" id="txtTestResult" cols="100"
rows="8"></textarea>
</p>
<p>
<label>
<input type="button" name="cmdTest" id="cmdTest" value="TEST"
onclick="doTest()" />
</label>
<label>
<input type="button" name="cmdMatch" id="cmdMatch" value="MATCH"
onclick="findMatches" />
</label>
<label>
<input type="reset" name="cmdClearForm" id="cmdClearForm" value="Reset Form" />
</label>
</p>
<p>&nbsp;</p>
</form>
</body>
</html>
</code>
Any help ...


Tom
__________________
Thomas G Magaro
  #2 (permalink)  
Old November 10th, 2011, 03:33 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 18 Times in 17 Posts
Default

Howdy, Tom.

If you're going to use document.formName syntax, then the form element needs a name attribute:

Code:
<form id="form1" name="form1">
The Following User Says Thank You to jmcpeak For This Useful Post:
flashmanTom (November 12th, 2011)
  #3 (permalink)  
Old November 11th, 2011, 11:06 AM
Authorized User
Points: 222, Level: 4
Points: 222, Level: 4 Points: 222, Level: 4 Points: 222, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2007
Location: Phoenix, AZ, USA.
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default Attribute has a newer construct

Hi Jeremy,

Thanks for the response.

I tried using the name attribute, but I get the error, "Warning 2 Validation (XHTML 1.0 Transitional): Attribute 'name' is considered outdated. A newer construct is recommended. C:\Users\Tom Magaro\Desktop\Tom's Stuff\Eagle Automation\Beginning Javascript\Chapter09\Example1.htm 59 22 C:\...\Chapter09\

Tom
__________________
Thomas G Magaro
  #4 (permalink)  
Old November 11th, 2011, 01:06 PM
Authorized User
Points: 222, Level: 4
Points: 222, Level: 4 Points: 222, Level: 4 Points: 222, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2007
Location: Phoenix, AZ, USA.
Posts: 48
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Hi again, Jeremy,

I didn't notice that I was only getting a warning on the name attribute.

However, my field names are still not recognized.

Tom
__________________
Thomas G Magaro


Similar Threads
Thread Thread Starter Forum Replies Last Post
contentsRichTextBox not recognized Mark P. BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 5 May 9th, 2011 03:02 PM
access module's are not recognized behraster Access VBA 1 January 22nd, 2010 09:13 AM
ruby is not recognized.... Crippy RoR Ruby on Rails 1 July 16th, 2008 08:37 AM
not recognized nachtegaal9999 ASP.NET 1.0 and 1.1 Basics 0 April 25th, 2006 02:04 PM
'net' is not recognized as a command ababb BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 7 December 20th, 2004 02:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.