Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript 4th Edition
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #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
Reply With Quote
  #2 (permalink)  
Old November 10th, 2011, 03:33 PM
jmcpeak's Avatar
Wrox Author
Points: 361, Level: 6
Points: 361, Level: 6 Points: 361, Level: 6 Points: 361, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 77
Thanks: 0
Thanked 12 Times in 12 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">
Reply With Quote
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
Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04: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 09:37 AM
not recognized nachtegaal9999 ASP.NET 1.0 and 1.1 Basics 0 April 25th, 2006 03: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



All times are GMT -4. The time now is 01:45 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.