In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to achieve form verification in JavaScript. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
HTML forms (form) are usually used to collect user information, such as name, email address, location, age, and so on.
However, it is quite possible that some users may not enter the data you expect. HTML form validation can be done through JavaScript.
To avoid unnecessary pressure on server resources, you can use JavaScript to validate form data on the client (user system). Incorrect information is not submitted to the background server-this is called client authentication. This article will introduce this kind of verification
There are generally two ways of form validation.
Client-side verification: JS is executed directly on the client side for verification, and there is no interaction with the server during the verification process.
Server-side verification: the page sends the verification information back to the server, which verifies, and sends the verification result back to the client.
Both authentication are necessary, because the client authentication security is not too high, but it can prevent more than 80% of users from misoperation, reduce the pressure on the server side, and the speed is very fast, and the user experience is high. Do not think that with the client-side verification, there is no need for the server-side verification, the client-side verification is easy to bypass, the server-side verification security is relatively high, so the general verification two verifications need to be written. ]
Example 1, a simple example
Simple example of form validation: function validateForm () {var x=document.forms ["myForm"] ["fname"] .value; if (x==null | | x _ name = "") {/ / alert ("name must be filled in"); usernameerror [XSS _ clean] = "name must be filled in"; return false;} else {usernameerror [XSS _ clean] = "correct"; return true;}}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.