Javascript / html / php自动错误检查[关闭]

Javascript / html / php自动错误检查[关闭]

问题描述:

I'm pretty new to HTML and i was wondering if there was a way to have constant/instant error checking on forms.

So for example there is a user putting in a username. the username must be at least 5 characters but no more then 15. If the user hasn't entered any data an error will appear on the screen (not a popup) once the user has input 5-15 characters the error will disappear.

I was wondering how i could go about making this happen rather then having to have the user hit submit every time to check the form for errors. I can use JavaScript (since that's what I've used to do other error checking) to some degree and i'd prefer to not use php but i will if it's necessary to complete this.

So i'm wondering where someone can point me in the right direction in order to read about this or provide me with the function in order to have it automatically detect errors.

If you have any questions or need more information let me know! i'll do my best to provide it. Sorry if it's a little ambiguous.

http://imgur.com/a/d9n5X

I've provided images on what it could possibly look like. So the first image an error appears due it not fitting the requirements of 5-15 characters. The second image fits it so the error disappears. I hope this helps!

Thanks in advance!

我是HTML新手,我想知道是否有办法进行常量/即时错误检查 表格。 p>

例如,有一个用户输入用户名。 用户名必须至少为5个字符,但不得超过15个。 如果用户未输入任何数据,则一旦用户输入5-15个字符,屏幕上将出现错误(不是弹出窗口),错误将消失。 p>

我想知道如何让这种情况发生,而不是每次都要让用户点击提交以检查表单是否有错误。 我可以在某种程度上使用JavaScript(因为那是我以前做过的其他错误检查),我宁愿不使用php,但如果有必要完成这个,我会的。 p>

所以我想知道有人能指出我正确的方向,以便阅读或提供我的功能,以便让它自动检测错误。 p>

如果你有 任何问题或需要更多信息让我知道! 我会尽我所能提供它。 对不起,如果它有点含糊不清。 p>

http://imgur.com/a / d9n5X p>

我已经提供了它可能看起来像的图像。 因此第一个图像出现错误,因为它不符合5-15个字符的要求。 第二个图像适合它,因此错误消失。 我希望这会有所帮助! p>

提前致谢! p> div>

Data form validation would be the best way to accomplish this.

<form>
  <label>
    Restricted Input
    <input pattern=".{5,15}" required title="Value must be between 5 and 15 characters." />
  </label>
  <label>
    Unrestricted Input
    <input />
  </label>
  <input type="submit" value="Submit" />
</form>

</div>