This example describes how JavaScript is a simple way to determine whether the input is legitimate. Share to everyone for your reference, specific as follows:
The idea of detecting the illegal character detection in the content of user input
1, the definition of a valid string (source string)
2, get the user input content
3, loop out the user input every character, go to the source string to find
1), search found, return the location of the string lookup
2), did not find the return-1, we just use-1 to detect the user input is legitimate
<! DOCTYPE HTML PUBLIC "-//w3c//dtd XHTML 1.0transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
More readers interested in JavaScript-related content can view the site topics: "JavaScript switching effects and tips summary", "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and tips summary", " JavaScript error and debugging skills Summary, JavaScript data structure and algorithm skills summary, JavaScript traversal algorithm and skills summary and JavaScript mathematical calculation usage Summary
I hope this article will help you with JavaScript programming.