简体   繁体   English

CENTOS Lamp服务器上的HTML5验证

[英]HTML5 validation on CENTOS Lamp server

I have a form: 我有一个表格:

<form method"post" action="#" class="form-horizontal" id="form">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email:</label>
    <div class="col-sm-10">
      <input type="email" name="email" placeholder="Email" class="form-control" id="email" required/>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Subject:</label>
    <div class="col-sm-10">
      <input type="text" name="subject" placeholder="Subject" class="form-control" id="subject" required/>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Message:</label>
    <div class="col-sm-10">
      <textarea name="message" rows="4" class="form-control" placeholder="Message" id="message" required></textarea>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-primary btn-lg btn-block" id="send">Send</button>
    </div>
  </div>
  <div class="form-group hidden" id="successMsg">
    <label class="col-sm-2"></label>
    <label class="col-sm-10" style="color:#198C19;">Thanks for your message!</label>
  </div>
</form>

Which I would like to have validated and have the cool little HTML5 popups next to it to denote that it is a required field, or that it is not an email address for the type="email" input element. 我想对其进行验证,并在其旁边添加一些酷炫的HTML5弹出窗口,以表示它是必填字段,或者它不是type="email"输入元素的电子邮件地址。 I had this working while on my local server on my machine. 我在机器上的本地服务器上进行此工作。 But after moving it to my CentOS server it no longer works. 但是将其移至我的CentOS服务器后,它将不再起作用。 I am running LAMP on CentOS. 我在CentOS上运行LAMP。 How might I get this to work? 我如何才能使它正常工作? I thought it was built into HTML5. 我以为它内置在HTML5中。 Also is it a possibility I have to do anything other than declare a doctype of <!DOCTYPE html> to ensure that it is treated as HTML5? 另外,除了声明<!DOCTYPE html>的文档类型以确保将其视为HTML5之外,我还需要做其他任何事情吗?

I've confirmed that this code does work. 我已经确认此代码可以正常工作。 BTW: you mentioned your server; 顺便说一句:您提到您的服务器; that really should not matter in the case of html; 对于html来说,这确实不重要; so long as the server sends the html, it's the browser that renders the markup (strictly client-side) 只要服务器发送html,它就是呈现标记的浏览器(严格是客户端)

For sake of clarity, and just in case another tag is affecting the rendering, here is the complete example I tried on my local server (worked in IE11, FF28, chrome 33.0.1750.154 m and chrome canary) 为了清楚起见,以防万一另一个标签影响渲染,这是我在本地服务器上尝试过的完整示例(在IE11,FF28,chrome 33.0.1750.154 m和chrome canary中工作)

<!doctype html>
<html>
<body>
<form method"post" action="#" class="form-horizontal" id="form">
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">Email:</label>
    <div class="col-sm-10">
      <input type="email" name="email" placeholder="Email" class="form-control" id="email" required/>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Subject:</label>
    <div class="col-sm-10">
      <input type="text" name="subject" placeholder="Subject" class="form-control" id="subject" required/>
    </div>
  </div>
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Message:</label>
    <div class="col-sm-10">
      <textarea name="message" rows="4" class="form-control" placeholder="Message" id="message" required></textarea>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" class="btn btn-primary btn-lg btn-block" id="send">Send</button>
    </div>
  </div>
  <div class="form-group hidden" id="successMsg">
    <label class="col-sm-2"></label>
    <label class="col-sm-10" style="color:#198C19;">Thanks for your message!</label>
  </div>
</form>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM