JavaScript authentication is a digital

Source: Internet
Author: User

JavaScript restricts the input to only numbers, determines the value of the Event.keycode, and restricts it to numbers only, and if it is not a number, returns an error and, if it is a number, continues.

Let me show you how to verify that JavaScript is a number another way, by using the following function:

function Isnumber (onum)

{

if (!onum) return false;

var strp=/^\d+ (\.\d+)? $/;

if (!strp.test (Onum)) return false;

try{

if (parsefloat (onum)!=onum) return false;

}

catch (ex)

{

return false;

}

return true;

}

This JavaScript code is very concise, you can see. Http://map.sogou.com/poi/1_D1000058002509.htm

There is a more stupid method, you can also see, learn

Next time you put a regular verification number.

The simplest JavaScript validation is not a number code as follows:

Using the Sinan function, click here to see the isNaN function description

JavaScript authentication is a digital

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.