JQuery can only enter the digital method

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

The method for input validation text box, if the input is digital, prompt "√". Otherwise, suggesting that “ required, and only the input digital character”.

Online experience:

The complete code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>JQuery can only enter numbers -- Ke Leyi</title>

<script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js"></script>

<style>

.inputtips{color:Red;}

</style>

</head>

<body>

<div>

<script type="text/javascript" src="http://keleyi.com/kineryi/js/gggg336x280a.js"></script>

</div>

<div>

Please enter: <input type= "text" id= "number_keleyi_com" /> <span id= "number_keleyi_com_tips" class= "inputtips" > </span> <br /> <input value= "verification" type="button" />

<br />

If the input is the numbers, there is no hint. Otherwise it will pop-up prompts.

<br />

<a href="http://keleyi.com/a/bjac/tv16sjeb.htm" target="_blank">The original</a>

</div>

<script type="text/javascript">

//Verification of digital method, if the input is digital, prompt "√". Otherwise, suggesting that “ required, and only the input digital character”

//Inputid input box ID

function IsPositiveIntegra(inputid) {

$("#" + inputid).blur(function () {

$("#" + inputid).val()

var reg_keleyi_com = /^[-+]?\d+$/;

if (reg_keleyi_com.test($("#" + inputid).val())) {

$("#" + inputid + "_tips").text("√");

return true;

}

else {

$("#" + inputid + "_tips").text("Required, and can only enter a numeric character");

$("#" + inputid).focus();

return false;

})

}

//Use

$(document).ready(

function () {

IsPositiveIntegra("number_keleyi_com"); //Using the above method to verify the ID number_keleyi_com input box

$("#number_ke"+"leyi_com").focus();

}

)

</script>

</body>

</html>

This paper:

The original

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Gina at November 15, 2013 - 6:55 PM