简体   繁体   English

单击 Bootstrap 中的按钮时,打开带有验证的模态表单

[英]Open a modal form with validation when clicking on a button in Bootstrap

I have a .container > .row > .col-*-4 (3x)我有一个.container > .row > .col-*-4 (3x)

Inside each column I have a share button.在每一列中,我都有一个分享按钮。 I need that button to pop-up a modal with a form with validation conditions.我需要那个按钮来弹出一个带有验证条件的表单的模式。

For Example :例如

Please enter your name (must be at least one upper letter, 2 characters long, full name)请输入您的姓名(必须至少为 1 个大写字母、2 个字符长、全名)

  • Natalya Smooth (correct) Natalya Smooth(正确)
  • natalya S (incorrect)娜塔莉亚 S(错误)

How can I do this?我怎样才能做到这一点?

You can use pattern for the your text field:您可以在文本字段中使用pattern

<form >
  Name: 
  <input type="name" name="nm" pattern="(?=.*[a-z])(?=.*[A-Z]).{2,}" 
         title="Must contain at one uppercase and at least 2 or more characters">
  <input type="submit">
</form>

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

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