Some common form submission Detection Functions

Source: Internet
Author: User
Tags microsoft frontpage

Function getlenb (tstr)
{
J = 0
For (I = 0; I <tstr. length; I ++)
{
If (tstr. charcodeat (I)> 255)
J ++;
J ++;

}
Return J;
}

Function checkint (tstr)
{
Re =/[^ 0-9]/;
Rp = tstr. Search (re );
Return RP;
}

Function checkhz (tstr)
{
For (I = 0; I <tstr. lengt; I ++)
If (tstr. charcodeat (I)> 255)
{
Return 1;
Break;
}
// Alert (string. fromcharcode (258 ))
Return 0;

}

Function checkstr (tstr)
{
// Re =/[^ a-zA-Z0-9 _]/;
Re = // w /;
Rp = tstr. Search (re );
Return RP;

}
Function checkhtml (tstr)
{
// Re =/[^ a-zA-Z0-9 _]/;
Re =/<(. *)>. * <// 1> /;
Rp = tstr. Search (re );
Return RP;

}

Function checkblank (tstr)
{
// Re =/[^ a-zA-Z0-9 _]/;
Re = // s /;
Rp = tstr. Search (re );
Return RP;

}

Function checkemail (tstr)
{
RE1 =/([/W/-/.]) + [@] {1} ([/W/-]) + (/. [/W/-]) + /;
Rp1 = tstr. Search (RE1 );

Re2 =/[^ a-zA-Z0-9 _/./-/@]/;
RP2 = tstr. Search (re2 );
// Alert (rp1)
If (rp1 =-1 | RP2! =-1)
Return false;
Else
Return true;
}

Function checksqlstr (tstr)
{
RE1 =/[/^/s ',/S/$]/;

Rp1 = tstr. Search (RE1 );
// RP2 = tstr. Search (re2 );
If (rp1! =-1)
Return false
Else
Return true;

}

Another validation uses a regular expression:

<HTML>

<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta name = "generator" content = "Microsoft FrontPage 4.0">
<Meta name = "progid" content = "FrontPage. Editor. Document">
<Title> Regular Expression 1 </title>
</Head>

<Body>
<Form method = post action = "">
For a regular expression <br> regular. Only numbers and English letters can be entered:
<Input onkeyup = "value = value. Replace (/[/W]/g ,'')"
Onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^/d]/g, '')"> <br> „. only numbers can be entered:
<Input onkeyup = "value = value. Replace (/[^/d]/g ,'')"
Onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^/d]/g, '')"> <br> .... Only the full-width fields can be entered:
<Input onkeyup = "value = value. replace (/[^/uff00-/Uffff]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^/uff00-/Uffff]/g, '')"> <br> Reset †. only Chinese characters can be entered:
<Input onkeyup = "value = value. Replace (/[-~] /G, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^/u4e00-/u9fa5]/g, '')"> <br>
<Input type = "Submit">
</Form>

<P> & quot; ^ // D + $ & quot; // non-negative integer (positive integer + 0) <br>
& Quot; ^ [0-9] * [1-9] [0-9] * $ & quot; // positive integer <br>
& Quot; ^ (-// D +) | (0 +) $ & quot; // non-positive integer (negative integer + 0) <br>
& Quot; ^-[0-9] * [1-9] [0-9] * $ & quot; // negative integer <br>
& Quot; ^ -? // D + $ & quot; // integer <br>
& Quot; ^ // D + (//. // D + )? $ & Quot; // non-negative floating point number (Positive floating point number + 0) <br>
& Quot; ^ ([0-9] + //. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * //. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ & quot; // Positive floating point number <br>
& Quot; ^ (-/d + (//. // D + )?) | (0 + (//. 0 + )?)) $ & Quot; // non-Positive floating point number (negative floating point number)
+ 0) <br>
& Quot; ^ (-([0-9] + //. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * //. [0-9] +) | ([0-9] * [1-9] [0-9] *) $ & quot; // negative floating point number <br>
& Quot; ^ (-? // D +) (//. // D + )? $ & Quot; // floating point number <br>
& Quot; ^ [A-Za-Z] + $ & quot; // a string consisting of 26 letters <br>
& Quot; ^ [A-Z] + $ & quot; // string consisting of 26 uppercase letters <br>
& Quot; ^ [A-Z] + $ & quot; // a string consisting of 26 lowercase letters <br>
& Quot; ^ [A-Za-z0-9] + $ & quot; // string consisting of digits and 26 letters <br>
& Quot; ^ // W + $ & quot; // a string consisting of digits, 26 English letters, or underscores <br>
& Quot; ^ [// w-] + (//. [// w-] +) * @ [// w-] + (//. [// w-] +) + $ & quot; // email address <br>
& Quot; ^ [A-Za-Z] +: // (// W + (-/W + )*)(//. (// W + (-/W + )*))*(//? // S *)? $ & Quot; // URL </P>

</Body>

</Html>

 

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.