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

Summary of JQuery's method of judging positive integers

小云云
小云云Original
2017-12-30 14:59:582125browse

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;
 }

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!

Statement:
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