Setting text field to accept only alphabetical characters.

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Oct 2008
Posts: 2
Reputation: cj1 is an unknown quantity at this point 
Solved Threads: 0
cj1 cj1 is offline Offline
Newbie Poster

Setting text field to accept only alphabetical characters.

 
0
  #1
Oct 26th, 2008
Hello all.

I am unable to solve two problems creating a contacts form using dreamweaver CS3. My other problem is posted under the heading, "Modify code created with Dreamweaver CS3, to compare two text feilds".

For this posting, can someone please tell me how to modify my code, pasted below, so that
the "First Name" and "Last Name" text fields are restricted to accepting only alphabetical characters.

Thank you

Here's my current code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="form1" method="post" action="">
<p>First Name
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="sprytextfield1">
<input type="text" name="First_Name" id="First_Name" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></p>
<p>Last Name
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="sprytextfield2">
<input type="text" name="First_Name2" id="First_Name2" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></p>
<p>&nbsp;</p>
<p>Contact Tel
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="sprytextfield3">
<input type="text" name="Contact_Tel" id="Contact_Tel" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Please enter numerical characters only.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></p>
<p>Confirm Contact Tel<span id="sprytextfield4">
<input type="text" name="Confirm_Contact_Tel" id="Confirm_Contact_Tel" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Please enter numerical characters only.</span><span class="textfieldMinCharsMsg">Minimum number of characters not met.</span><span class="textfieldMaxCharsMsg">Exceeded maximum number of characters.</span></span></p>
<p>&nbsp;</p>
<p>
<input type="submit" name="Submit_button" id="Submit_button" value="Submit" />
</p>
</form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {minChars:2, maxChars:15});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {minChars:2, maxChars:15});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "integer", {minChars:5, maxChars:15});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "integer", {minChars:5, maxChars:15});
//-->
</script>
</body>
</html>
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 1
Reputation: lheenardz is an unknown quantity at this point 
Solved Threads: 0
lheenardz lheenardz is offline Offline
Newbie Poster

Re: Setting text field to accept only alphabetical characters.

 
0
  #2
Nov 6th, 2008
How to set text field as number. That cannot enter text only number.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 1
Reputation: McFant is an unknown quantity at this point 
Solved Threads: 0
McFant McFant is offline Offline
Newbie Poster

Re: Setting text field to accept only alphabetical characters.

 
0
  #3
Aug 28th, 2009
Sorry but your code is not working as suggested. In the name field it accepts numerical values instead of alphabetical only
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum


Views: 3496 | Replies: 2
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC