Home > Web Front-end > JS Tutorial > Summary of JQuery's method of judging positive integers

Summary of JQuery's method of judging positive integers

小云云
Release: 2017-12-30 14:59:58
Original
2182 people have browsed it

This article mainly introduces JQuery to determine positive integers. Detailed code is attached for everyone to see the specific method. Friends in need can refer to it. I hope it can help everyone.

var totalPage = document.getElementById("totalPage").value.trim();//获取总页
 var reg=/^[1-9]\d*$/; //由 1-9开头 的正则表达式
 //先判断是否为整数 在判断 是否在 1-总页 整数范围之内
 if(reg.test(searchBox)){
  if(parseInt(searchBox) > 0 && parseInt(searchBox) <= totalPage){
   alert(searchBox);
  }else{
   alert("输入的页码超出指定范围!!!");
   document.getElementById("searchBox").value = ""; //清空
   return;
  }
 }else{
 alert("请输入合法的整数页码!!");
 document.getElementById("searchBox").value = ""; //清空
 return;
 }
Copy after login

Related recommendations:

php function code to judge positive integers

Judge integers_PHP

Summary of various methods for judging integers in JavaScript_javascript skills

The above is the detailed content of Summary of JQuery's method of judging positive integers. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template