Search code examples
htmlformsvalidation

html how do I make required fields in forms


Is there any way i could make fields required. I tried the using required="required" in the input tag, but it still did not work. is there any other way?

<input name="Forename" type="text" required="required" id="Forename2" onkeyup="allLetter(this)"/>

Solution

  • The required attribute can simply be included like this:

    <input required>
    

    So in your case, remove the attribute tag:

    <input name="Forename" type="text" required id="Forename2" onkeyup="allLetter(this)"/>