JS detects if username and password are correct

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax beginners code document function javascript name password

This article is a simple JavaScript detection username and password is correct function Oh, if you are JS beginners can look at this code OH.

<script language= ' JavaScript ' >
function XGJC (YHM,MM,XMM,QM)
{
if (yhm== "")
{
Alert (' username cannot be empty! ');
Document.de.yhm.focus ();
return false;
}
if (MM!=XMM)
{
Alert (' Two input passwords inconsistent! ');
Document.de.mm.focus ();
return false;
}
if (qm.length>=49)
{
Alert (' Signed too long! ');
Document.de.qm.focus ();
return false;
}
}

function ZCJC (YHM,MM,XMM,QM)
{
if (yhm== "")
{
Alert (' username cannot be empty! ');
Document.zc.yhm.focus ();
return false;
}
if (Yhm.indexof ("") >=0 | | Yhm.indexof ("<") >=0 | | Yhm.indexof (">") >=0 | | Yhm.indexof (".") >=0)
{
Alert (' username cannot have garbled! ');
Document.zc.yhm.focus ();
return false;
}

if (mm== "")
{
Alert (' Password cannot be empty! ');
Document.zc.mm.focus ();
return false;
}
if (MM!=XMM)
{
Alert (' Two input passwords inconsistent! ');
Document.zc.mm.focus ();
return false;
}
if (Mm.indexof ("") >=0 | | Mm.indexof ("<") >=0 | | Mm.indexof (">") >=0 | | Mm.indexof (".") >=0)
{
Alert (' Can't have garbled! ');
Document.zc.mm.focus ();
return false;
}
if (qm.length>=49)
{
Alert (' Signed too long! ');
Document.zc.qm.focus ();
return false;
}
}
</script>

Here is the HTML code

&lt;form name= "Zc" action= "TB_ZC.ASP?CZ=ZCCG" method= "POST" &gt;


&lt;div align= "left" &gt;


&lt;p&gt; Username:


&lt;input name= "YHM" type= "text" size= "&gt;


*&lt;br&gt;


Password:


&lt;input name= "mm" type= "password" size= "&gt;
"

*&lt;br&gt;


Password:


&lt;input name= "qxmm" type= "password" size= "&gt;
"

*&lt;br&gt;


Personality Signature:


&lt;input type= "text" Name= "QM" size= "" maxlength= "&gt;
"

&lt;br&gt;


e-mail:


&lt;input name= "Lxfs" type= "text" size= "M" maxlength= "&gt;
"

&lt;/p&gt;


&lt;p align= "center" &gt;


&lt;input type= "Submit" Name= "ZC" value= "registered" onclick= "Return ZCJC (Yhm.value,mm.value,qxmm.value,qm.valu e); &gt;


&lt;/p&gt;


&lt;/div&gt;


&lt;/form&gt;


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.