Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!