The following editor will bring you an example of using JavaScript to complete the form verification on the registration page. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look
1. Step analysis
The first step: Determine the event (onsubmit) and provide It binds a function
Step 2: Write this function (get the data input by the user
Step 3: To the user Judge the entered data
Step 4: The data is legal (allow the form to be submitted)
Step 5: The data is illegal (give an error message and do not allow the form to be submitted)
Question: How to control form submission?
About the event onsubmit: Generally used for form submission, then a return value needs to be given when defining the function.
onsubmit = return checkForm()
2. Complete the registration page form verification
注册页面
| |||
首页 手机数码 电脑办公 鞋靴箱包 家用电器 | |||
关于我们 联系我们 招贤纳士 法律声明 友情链接 支付方式 配送方式 服务声明 广告声明 Copyright © 2005-2016 hh商城 版权所有 |
Use regular expressions in the verification and confirmation part of the password (no need to remember, look for documents when needed)
Regular expression.test (verification object) is true if it meets the conditions, if it is false, it is incompatible.
The above is the detailed content of Example sharing of JavaScript implementation of registration page form verification. For more information, please follow other related articles on the PHP Chinese website!