duandanbeng1829 2015-09-23 19:45
浏览 54
已采纳

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!

  • 写回答

1条回答 默认 最新

  • duanlei5339 2015-09-23 20:03
    关注

    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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)