Source Code:<html>
<head>
<title>Mutiple function call!!</title>
<script language="javascript">
function validate_number() {
var str=document.frmbanksignup.txttel.value;
if (isNaN(str) == true) {
alert("Telephone number should be numeric value!!");
document.frmbanksignup.txttel.value = "";
document.frmbanksignup.txttel.focus();
return false;
}
}
function validate_email() {
if(valid()) {
return true;
}
return false;
}
function valid() {
var str=document.frmbanksignup.txteadd.value
if(str.indexOf('@') < 0) {
alert("Your have entered an Invalid email address");
document.frmbanksignup.txteadd.value = "";
document.frmbanksignup.txteadd.select();
return false;
}
if(str.indexOf('.') < 0) {
alert("Your have entered an Invalid email address");
document.frmbanksignup.txteadd.value = "";
document.frm1.txteadd.select();
return false;
}
if (str.indexOf('@') > str.indexOf('.')) {
alert("Invalid address!! The '@' symbol must comes before the '.' Symbol of any email ddress!!");
document.frmbanksignup.txteadd.value = "";
document.frm1.txteadd.select();
return false;
}
alert("Index of @: " + str.indexOf('@') + " Index of . : " + str.indexOf('.'));
return true;
}
function Chk_Null() {
if (document.frmbanksignup.txtname.value == "") {
alert("Name can't be empty!!");
document.frmbanksignup.txtname.focus();
return false;
}
else if (document.frmbanksignup.txtlocation.value == "") {
alert("Location name shouldn't be empty!!");
document.frmbanksignup.txtlocation.focus();
return false;
}
else if (document.frmbanksignup.txttel.value == "") {
alert("Contact Number shouldn't be empty!!");
document.frmbanksignup.txttel.focus();
return false;
}
else if (document.frmbanksignup.txteadd.value == "") {
alert("E-mail address shouldn't be empty!!");
document.frmbanksignup.txteadd.focus();
return false;
}
else if (document.frmbanksignup.txtpass1.value == "") {
alert("Password field shouldn't be empty!!");
document.frmbanksignup.txtpass1.focus();
return false;
}
else if (document.frmbanksignup.txtpass2.value == "") {
alert("Please confirm your password!!");
document.frmbanksignup.txtpass2.focus();
return false;
}
}
function confirm_password() {
if (document.frmbanksignup.txtpass1.value != document.frmbanksignup.txtpass2.value) {
alert("Your password doesn't match!! Please Try again!!");
document.frmbanksignup.txtpass1.value = "";
document.frmbanksignup.txtpass2.value = "";
document.frmbanksignup.txtpass1.focus();
return false;
}
}
</script>
<body>
<form name="frmbanksignup" method="post" action="Contents.html">
<table width="372" border="3" cellspacing="5" cellpadding="2">
<tr>
<td height="34" colspan="2" bgcolor="#B9E9F"><center><strong><u>Bank General Information!lt;/u></strong></center></td>
</tr>
<tr>
<td height="34" colspan="2"><font face="Calibri" color="#FF0000><b>All the fields should be filled.</b></font><td>
</tr>
<tr>
<td width="141" align="left">Name :</td>
<td width="198"><input name="txtname" type="text" size="25" /></td>
</tr>
<tr>
<td align="left">Location :</td>
<td><input name="txtlocation" type="text" size="25" /></td>
</tr>
<tr>
<td align="left">Contact No : </td>
<td><input name="txttel" type="text" size="25" onChange="return validate_number()"/></td>
</tr>
<tr>
<td align="left">E-mail address : </td>
<td><input name="txteadd" type="text" size="25" onChange="return validate_email()"/></td>
</tr>
<tr>
<td>Create Password : </td>
<td><input name="txtpass1" type="password" size="25" /></td>
</tr>
<tr>
<td>Confirm Password : </td>
<td><input name="txtpass2" type="password" size="25" onChange="return confirm_password()"/></td>
</tr>
<tr>
<td><input type="button" name="bttnchk" value="Check it" onClick="return chk_Null()" ></td>
<td><input type="reset" name="Reset" ></td>
</tr>
</table>
</form>
</body>
</html>
<head>
<title>Mutiple function call!!</title>
<script language="javascript">
function validate_number() {
var str=document.frmbanksignup.txttel.value;
if (isNaN(str) == true) {
alert("Telephone number should be numeric value!!");
document.frmbanksignup.txttel.value = "";
document.frmbanksignup.txttel.focus();
return false;
}
}
function validate_email() {
if(valid()) {
return true;
}
return false;
}
function valid() {
var str=document.frmbanksignup.txteadd.value
if(str.indexOf('@') < 0) {
alert("Your have entered an Invalid email address");
document.frmbanksignup.txteadd.value = "";
document.frmbanksignup.txteadd.select();
return false;
}
if(str.indexOf('.') < 0) {
alert("Your have entered an Invalid email address");
document.frmbanksignup.txteadd.value = "";
document.frm1.txteadd.select();
return false;
}
if (str.indexOf('@') > str.indexOf('.')) {
alert("Invalid address!! The '@' symbol must comes before the '.' Symbol of any email ddress!!");
document.frmbanksignup.txteadd.value = "";
document.frm1.txteadd.select();
return false;
}
alert("Index of @: " + str.indexOf('@') + " Index of . : " + str.indexOf('.'));
return true;
}
function Chk_Null() {
if (document.frmbanksignup.txtname.value == "") {
alert("Name can't be empty!!");
document.frmbanksignup.txtname.focus();
return false;
}
else if (document.frmbanksignup.txtlocation.value == "") {
alert("Location name shouldn't be empty!!");
document.frmbanksignup.txtlocation.focus();
return false;
}
else if (document.frmbanksignup.txttel.value == "") {
alert("Contact Number shouldn't be empty!!");
document.frmbanksignup.txttel.focus();
return false;
}
else if (document.frmbanksignup.txteadd.value == "") {
alert("E-mail address shouldn't be empty!!");
document.frmbanksignup.txteadd.focus();
return false;
}
else if (document.frmbanksignup.txtpass1.value == "") {
alert("Password field shouldn't be empty!!");
document.frmbanksignup.txtpass1.focus();
return false;
}
else if (document.frmbanksignup.txtpass2.value == "") {
alert("Please confirm your password!!");
document.frmbanksignup.txtpass2.focus();
return false;
}
}
function confirm_password() {
if (document.frmbanksignup.txtpass1.value != document.frmbanksignup.txtpass2.value) {
alert("Your password doesn't match!! Please Try again!!");
document.frmbanksignup.txtpass1.value = "";
document.frmbanksignup.txtpass2.value = "";
document.frmbanksignup.txtpass1.focus();
return false;
}
}
</script>
<body>
<form name="frmbanksignup" method="post" action="Contents.html">
<table width="372" border="3" cellspacing="5" cellpadding="2">
<tr>
<td height="34" colspan="2" bgcolor="#B9E9F"><center><strong><u>Bank General Information!lt;/u></strong></center></td>
</tr>
<tr>
<td height="34" colspan="2"><font face="Calibri" color="#FF0000><b>All the fields should be filled.</b></font><td>
</tr>
<tr>
<td width="141" align="left">Name :</td>
<td width="198"><input name="txtname" type="text" size="25" /></td>
</tr>
<tr>
<td align="left">Location :</td>
<td><input name="txtlocation" type="text" size="25" /></td>
</tr>
<tr>
<td align="left">Contact No : </td>
<td><input name="txttel" type="text" size="25" onChange="return validate_number()"/></td>
</tr>
<tr>
<td align="left">E-mail address : </td>
<td><input name="txteadd" type="text" size="25" onChange="return validate_email()"/></td>
</tr>
<tr>
<td>Create Password : </td>
<td><input name="txtpass1" type="password" size="25" /></td>
</tr>
<tr>
<td>Confirm Password : </td>
<td><input name="txtpass2" type="password" size="25" onChange="return confirm_password()"/></td>
</tr>
<tr>
<td><input type="button" name="bttnchk" value="Check it" onClick="return chk_Null()" ></td>
<td><input type="reset" name="Reset" ></td>
</tr>
</table>
</form>
</body>
</html>
No comments:
Post a Comment