Home > Blockchain >  In HTML form "required" attribute is not working
In HTML form "required" attribute is not working

Time:10-20

For the textarea , the field doesn't tell that is required to be filled and user can save the form with empty text area.

<tr>
  <td>Summarys&nbsp;<input type="text" path="SummaryInfo" id="SummaryInfo" style="text-align: right" size="5" maxlength="5"  onkeypress="if (event.keyCode < 48 || event.keyCode > 57) (event.preventDefault) ? event.preventDefault() : event.returnValue = false;"  onkeyup="javascript:this.setAttribute('value', this.value);" required/></td>
                                                </tr>

CodePudding user response:

It's input, not html:input

Also add a type to your input, like <input type="text" />

CodePudding user response:

There is a small error. Instead of html:input just input and required will then work.

<tr>
  <td>Summarys&nbsp;
    <form action="/">  
      <input type="text" path="SummaryInfo" id="SummaryInfo" style="text-align: right" size="5" maxlength="5"  onkeypress="if (event.keyCode < 48 || event.keyCode > 57) (event.preventDefault) ? event.preventDefault() : event.returnValue = false;"  onkeyup="javascript:this.setAttribute('value', this.value);" required/>
      <input type="submit">
    </form> 
  </td>
</tr>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

And an important hint from @Max Alexander Hanna. Don't forget the type.

  • Related