Home / Web / How to check and confirm password using JavaScript?
password in js

How to check and confirm password using JavaScript?

JavaScript (JS) is a scripting language .Which was developed by Netscape. JavaScript is used in HTML.

Password is important for securing our profile or content on website or webpage. So in below JavaScript code we are discussing about how to Check the Password & Confirm Password with the help of  JavaScript.

<!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></title>
<script type=”text/javascript”>
function check(txt1, txt2) {
if (txt1 == ” ” || txt1.length == 0 || txt2 == ” ” || txt2.length == 0) {
alert(“Can’t Leave Textbox Empty”); return;
}

if (isNaN(txt1) || isNaN(txt2)) {
alert(“Please Enter Number Only”); return;
}
var txt1Int = parseInt(txt1);var txt2Int = parseInt(txt2);
if (txt1Int==txt2Int) {
document.write(“<h1>THANK YOU FOR CORRECT INPUT. HAVE A NICE DAY!</h1>”);
}
else {
alert(“Password & Compare Password Should Match”);document.getElementById(“txtIn2”).value = “”;
}
}
</script>
<style type=”text/css”>
.style1
{
width: 513px;
}
</style>
</head>
<body>
<table border=”2″>
<tr>
<td colspan=”2″ align=center><b><u>Password & Compare Password Matching</u></b></td>
</tr>
<tr>
<td><b>First Entry:</b></td>
<td>
<input id=”txtIn1″ type=”text” value=”” /></td>
</tr>
<tr>
<td><b>Second Entry:</b></td>
<td><input id=”txtIn2″ type=”text” value=””/></td>
</tr>
<tr>
<td colspan=”2″ align=”center”>
<input id=”btnSubmit” type=”submit” value=”Check Duplicate” onclick=”check(txtIn1.value,txtIn2.value)”/></td>
</tr>
</table>
</body>
</html>

Learn creating game using JavaScript : Game Assignment Using Javascript

About Helpservices

About This site (allhelpservices.com) is dedicated to helping other bloggers learn the skills of blogging, wordpress, education, technology, social media sharing , SEO, Electronics, Earn Money From Blogging, Web hosting and web share their own experiences and promote the blogging medium. We started Allhelpservices in August 2015 mainly because we wanted to keep a record of what we wear learning from development and because we wanted to connect with other learners.

Check Also

style sheet

What are ways of inserting a style sheet?

Cascading Style Sheets (CSS) describe how documents are presented on screens, in print, or perhaps ...

Leave a Reply