Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda