SoFunction
Updated on 2025-03-03

JavaScript regular expressions check non-positive integer instances

Without further ado, let's take a look with the editor

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
 <title></title>
 <script type="text/javascript">
 function validation() {
 var val = ("txtNumber").value;
 var regu = /^((-\d+)|(0+))$/;
 if (val != "") {
 if (!(val)) {
  ("labResult"). = "red";
  ("labResult").innerHTML = "Verification failed!";
 } else {
  ("labResult"). = "green";
  ("labResult").innerHTML = "Verification was successful!";
 }
 }
 }
 </script>
</head>
<body>
 <input  name="txtNumber" type="text" />
 <input  name="btnValidation" type="button" value="check" onclick="validation()" />
 Verification results:<label  ></label>
</body>
</html>

The above is all the content of this article. I hope that the content of this article will help you study or work. I also hope to support me more!