What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

Validation does not work

Karl

New member
Joined
Dec 4, 2021
Messages
2
Reaction score
1
HTML Coins
0
Hi,

I'm a beginner in coding. I'm currently taking a course at Percipio and I've been struggling with a problem all day.

In my form the name should now be checked by using Javascript. More precisely, in my example, whether between 2 and 15 characters have been entered in the field firstname.

I've now made everything out except for the fields in question so that it is easier to see. In my opinion, I am compliant with the content of the training video. I didn't find a typo either, everything should be consistent as far as the names of the fields etc. are concerned.

I do not have a validation process or at least I cannot see the output of it. Can please someone give me a hint?


HTML:
<!DOCTYPE html>
<html>

<head>

  <title>My first HTML form</title>

  <script type="text/javascript">
    function validateFirstName() {
      var field = document.getElementByID("firstName").value;
      var regex = /^[a-zA-Z]{2,15}$/;
      if (regex.test(field))
        document.getElementByID("message").innerHTML = "Input accepted";
      else
        document.getElementByID("message").innerHTML = "Please enter between 2 and 15 letters";
    }
  </script>

</head>

<body>

  <H1>Your perfect vacation trip</H1>

  <form>
    Please enter your first name:<br>
    <input id="firstName" type="text" onblur="validateFirstName();"/><span id="message"></span><br><br>

</body>

</html>
 
Hi ani,
thank you for your reply.

Do you mean here:

```
<script type="text/javascript">
function validateFirstName() {
var field = document.getElementByID("").value;
```

This also do not seem to work.
 
replace: document.getElementByID("").value;
to: document.getElementByID("").value;

I believe it is: getElementById("enterYourId")
 
The next step in software design https://mlsdev.com/blog/hire-a-development-team is auxiliary documentation. Aside from formal validation techniques, auxiliary documentation is essential for capturing the concepts and methods used to model problem space. As the process continues, it's vital to ensure that your designs are functional and will meet the specifications of your project. Whether you want a simple web application or a complex application that is a complex piece of software, you can be sure that this process will produce a product that's worth the investment.
 
Last edited:
I have been trying to get into learning how to code for a while now but I have been able to do it. Reading about this now have picked on my interest again. I'm going to checkout Udemy courses and see which one to join in coding .
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back