Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

253
Vistas
How to validate a HTML textbox upon submit using JavaScript (Alpha characters only, more than 2 characters) cant seem to get the validation working
<!DOCTYPE html>
<html>
<head>
    <title>Form</title>
    <link rel="stylesheet" href="styles.css">

<script>

//Not sure the correct syntax for the validation of the textbox, trying to allow just alpha characters. If alpha characters are not entered message should appear. Upon click of submit button user should be presented with message depending on result.

funtion validate() {
    var Frmforename = document.getElementbyName("Frmforename")[0].value;

    var re = (/^[A-Za-z]+$/);

    if (re.test(Frmforename)) {
            alert("Correct.");
        }
    }
    else 
        (re.test(Frmforename)) {
            alert("Incorrect.");
</script>
</head>
<body>
<div>
<form>

    <form action = "donothing.html" method = "Post" name = "FrmRegister" class ="FrmForm" id = "FrmForm" onsubmit="validate()">

//Upon click of the submit button message should appear.

    Forename: <input type = "text" name = "Frmforename" id = "Frmforename" placeholder = "Please enter your forename" > <br><br>


    Surname: <input type = "text" name = "FrmSurname" placeholder = "Please enter your surname" > <br><br>

    Gender: 
    Male<input type = "radio" name = "FrmGender" value = "Male">
    Female<input type = "radio" name = "FrmGender" value = "Female"><br><br>
    
    Date Of Birth: <input type = "text" name = "FrmDateOfBirth" placeholder = "Please enter your DOB" > <br><br>

    Age: <input type = "text" name = "FrmAge" placeholder = "Please enter your Age" > <br><br>

    Course: <select name="FrmCourse" id="Course">

    <option value="Database">Database</option>
    <option value="Networks">Networks</option>
    <option value="Web Development">Web Development</option>
    </select> <br><br>
 
    Date: <input type = "text" name = "Date" placeholder = "Please enter the date" > <br><br>
    <input type ="Submit" name ="Submit" value ="Submit">
    </div>

</form>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda