A simple example of determining whether the value entered by the user is empty in js_javascript skills
WBOY
Release: 2016-05-16 17:07:40
Original
1042 people have browsed it
Determining whether the value entered by the user is empty in js is something that everyone uses a lot. There is nothing to write about. But I did it. The reason is just that I think my code is good. For your reference.
This is an excerpt from the user registration page in one of my projects. For most people, this is almost 100% experienced. Post the code, these codes are all written in js. It’s not difficult, it’s easy to understand. When you read it, you just need to distinguish between the two js classes. Front page code: reguser.aspx
/***************************************************** ******* * * Public js function * ****************************** **********************************/ function commonFunction() { // check value is null or empty this.checkIsEmpty = function(obj) { var flag = true; for(var i=0; i { var e = obj.item(i); if(e.isRequired) { if(e.value=='') { alert(e.errorSForEmpty); e.focus(); flag = false; break; } }
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn