0

Hi,

I have a form for registration and i would like to make Phone Number and other textboxes numeric and don't accept letters, i mean, if you write a letter 'p', for exemple it doesn'te write.

Can someone help me?

Thank You,
PF2G

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by stbuchok
0

http://www.cambiaresearch.com/articles/39/how-can-i-use-javascript-to-allow-only-numbers-to-be-entered-in-a-textbox

Google is your friend.

I've already done that, and it's not working

here's my TOP.PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Escola de Música de V.N.Gaia</title>

<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
<style type="text/css">

 <SCRIPT language=Javascript>
      <!--
      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
      //-->
   </SCRIPT>

</style>
</head>
<body>

<div id="banner">
<!--begin bann_menu-->
<img name="Untitled2" src="images/bann_menu.jpg" width="950" height="346" border="0" id="Untitled2" usemap="#m_Untitled2" alt="" /><map name="m_Untitled2" id="m_Untitled2">
<area shape="rect" coords="21,32,641,101" href="index.php" alt="" />
<area shape="rect" coords="726,299,882,345" href="contact.php" alt="" />
<area shape="rect" coords="503,299,659,345" href="cursos.php" alt="" />
<area shape="rect" coords="276,299,432,345" href="inscricao.php" alt="" />
<area shape="rect" coords="58,299,214,345" href="index.php" alt="" />
</map>
<!--end   bann_menu-->
</div>

<div id="content">
<div id="colTwo">
	<div class="latest-post">

and here's my registration.php:

<?PHP

include 'topo.php';

?>


<!-- content -->

   <div class="indent">

	<h2> Inscrição </h2>


<form action="envia.php" method="post" onsubmit="return validar()" >
  <fieldset>
   <legend> ALUNO </legend>
	
	  <br>
	  <div class="field"><label>Nome*: </label><input type="text" size="40" name = "nome"/></div>
      <br>	  
      <div class="field"><label>Data de Nascimento*: </label><input type="text" size="3" maxlength="2" name = "dia"/> / <input type="text" size="3" maxlength="2" name = "mes"/> / <input type="text" size="5" maxlength="4" name = "ano"/>  (DD/MM/AAAA)</div>
      <br>
      <div class="field"><label>Morada: </label><input type="text" onkeypress="return onlyNumbers();" size="39" name = "morada"/></div>
      <br>
      <div class="field"><label>Código Postal: </label><input id="txtChar" onkeypress="return isNumberKey(event)" type="text" name = "cp1"/> - <input type="text" size="4" maxlength="3" name = "cp2"/></div>
      <br>
      <div class="field"><label>Telemóvel*: </label><input id="txtChar" onkeypress="return isNumberKey(event)" type="text" name = "tele"/></div>
      <br>
	  Curso*: <select name="curso"> 
	  <option> Piano    </option>
	  <option> Orgão    </option>
	  <option> Guitarra </option>
	  <option> Violino  </option>
	  <option> Canto    </option>
	  <option> Bateria  </option>
	  <option> Saxofone </option>
	  <option> Flauta   </option>
	  <option> Baixo </option>
	  </select>
	  <br>
	  <br>
      <div class="field"><label>E-Mail*: </label><input type="text" value="" name = "email" size = "25"/></div>
	  <br>
	  Observações:
	  <br>
      <textarea cols="30" rows="7" name="obs"></textarea> 
  </fieldset>
  <br>
  <fieldset>
    <legend> ENCARREGADO DE EDUCAÇÃO  </legend>
	 
	  <br/>
      <div class="field"><label>Nome*: </label><input type="text" size="40" name = "nome_ee"/></div>
      <br/>
      <div class="field"><label>Morada: </label><input type="text" size="39" name = "morada_ee"/></div>
      <br/>
	  <div class="field"><label>Código Postal: </label><input type="text" size="5" maxlength="4" name = "cp1_ee"/> - <input type="text" size="4" maxlength="3" name = "cp2_ee"/></div>
	  <br/>
      <div class="field">Telemóvel*: </label><input type="text" size="10" maxlength="9" name = "tele_ee"/></div>
      <br/>
      <div class="field"><label>E-Mail*: </label><input type="text" value="" name = "email_ee" size = "25"/></div>
	  
  </fieldset>
      <br>
      * Campos Obrigatórios
	  <br/>
	  <input type="submit" value="Enviar">
      <input type="Reset" value="Apagar"> 
  
</form>
	
   </div>
</div>


<?PHP

include 'rodape.php';

?>
0

OMFG.

Thank you so much. That's the stuff :P

Thank you, again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.