当前位置:网站首页>Judge whether the string is empty
Judge whether the string is empty
2022-06-28 19:21:00 【liaowenxiong】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Check if the specified value is an empty string </title>
<script>
function test_1() {
// var name = document.getElementById("name").value;
// alert(name);
var name = null;
// var flag = isEmptyStr(name);
var flag = isEmptyStrV2(name);
alert(flag);
}
function test_2() {
var flag_1 = null == undefined; // true
var flag_2 = null === undefined; // false
alert(flag_1);
alert(flag_2);
}
function test_3(s) {
alert(s);
var flag = isEmptyStr(s);
alert(flag);
}
function isEmptyStr(s) {
if (s == undefined || s == null || s.trim() === '') {
return true
}
return false
}
function isEmptyStrV2(s) {
if (typeof s == 'string' && s.trim().length == 0) {
return true;
} else if (s == null) {
return true;
}
return false;
}
// Because the program will null Equate to undefined, So you can add the above function to if The conditional statement in the statement is simplified to the conditional statement shown in the following function
function isEmptyStr(s) {
if (s == undefined || s.trim() === '') {
return true
}
return false
}
</script>
</head>
<body>
<label for="name">name:</label>
<input id="name" type="text" name="name"/>
<button type="button" onclick="var name = document.getElementById('name').value;test_3(name);">Click Me!</button>
<!--<button type="button" onclick="test_1();">Click Me!</button>-->
<!--<button type="button" onclick="test_2();">Click Me!</button>-->
</body>
</html>
Reference resources :https://blog.csdn.net/K346K346/article/details/113182838
边栏推荐
- 基于趋势和季节性的时间序列预测
- 行业分析| 快对讲,楼宇对讲
- Shell script batch modify file directory permissions
- C language file operation
- SQL calculates daily new users and retention rate indicators
- Friends from Fujian, your old-age insurance is on the cloud!
- Full MySQL solution ubuntu/win10
- [C #] explain the difference between value type and reference type
- MongoDB系列之MongoDB工作原理简单介绍
- leetcode 1647. Minimum deletions to make character frequencies unique
猜你喜欢

Bayesian inference problem, MCMC and variational inference

春风动力携手华为打造智慧园区标杆,未来工厂创新迈上新台阶

Chunfeng power and Huawei work together to build a smart Park benchmark, and the future factory innovation will reach a new level

Understanding of closures

Leetcode 周赛299
![[unity3d] camera follow](/img/11/6309450f2b3ef33df558104549dc4c.png)
[unity3d] camera follow

Technical methodology of new AI engine under the data infrastructure upgrade window

Ffmpeg usage in video compression processing

Group programming TIANTI competition exercise - continuously updating

Openharmony - detailed source code of Kernel Object Events
随机推荐
智能计算系统2 bangc算子开发的demo (CPU和MLU270的异构编程流程)
如何通过W3school学习JS/如何使用W3school的JS参考手册
List adding timer (positive and countdown)
[unity3d] camera follow
Grafana biaxial graph with your hands
Can py SQL get the table structure?
华为云OneMeeting告诉你全场景会议这么开!
Mindspire series one loading image classification data set
在arm版本rk3399中搭建halo博客
About Significance Tests
Windows 64位下载安装My SQL
找出连续7天登陆,连续30天登陆的用户
Find out the users who log in for 7 consecutive days and 30 consecutive days
论文3 VScode&texlive&SumatraPDF打造完美书写论文工具
Rigid error: could not extract PIDs from PS output PIDS: [], Procs: [“bad pid
月环比sql实现
Openharmony - detailed source code of Kernel Object Events
try except 添加辅助新列
请问下flinkcdc用flinksql提交的话只能一个表提交一个任务吗?那有几千张表的时候还能这么
释放互联网价值的 Web3