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,

5 Years
Discussion Span
Last Post by stbuchok


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"
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml">
<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;


<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="" />
<!--end   bann_menu-->

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

and here's my registration.php:


include 'topo.php';


<!-- content -->

   <div class="indent">

	<h2> Inscrição </h2>

<form action="envia.php" method="post" onsubmit="return validar()" >
   <legend> ALUNO </legend>
	  <div class="field"><label>Nome*: </label><input type="text" size="40" name = "nome"/></div>
      <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>
      <div class="field"><label>Morada: </label><input type="text" onkeypress="return onlyNumbers();" size="39" name = "morada"/></div>
      <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>
      <div class="field"><label>Telemóvel*: </label><input id="txtChar" onkeypress="return isNumberKey(event)" type="text" name = "tele"/></div>
	  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>
      <div class="field"><label>E-Mail*: </label><input type="text" value="" name = "email" size = "25"/></div>
      <textarea cols="30" rows="7" name="obs"></textarea> 
    <legend> ENCARREGADO DE EDUCAÇÃO  </legend>
      <div class="field"><label>Nome*: </label><input type="text" size="40" name = "nome_ee"/></div>
      <div class="field"><label>Morada: </label><input type="text" size="39" name = "morada_ee"/></div>
	  <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>
      <div class="field">Telemóvel*: </label><input type="text" size="10" maxlength="9" name = "tele_ee"/></div>
      <div class="field"><label>E-Mail*: </label><input type="text" value="" name = "email_ee" size = "25"/></div>
      * Campos Obrigatórios
	  <input type="submit" value="Enviar">
      <input type="Reset" value="Apagar"> 


include 'rodape.php';



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.