Forums
This topic is locked
if any body can help me?!
22 Dec 2003 19:00:55 a aa posted:
Hi to All i have a problem and i need to a solution
its in dreamweaver mx
details : suppose you are feeling a fields ,you will fell them one by one ok,so i need to a "solution that not allow to the user to fell the second field or the third before the first" ???? please tell me how i can do it or if there is any tool ??
best Regards
Replies
Replied 23 Dec 2003 15:49:42
23 Dec 2003 15:49:42 Vince Baker replied:
You can do this by putting some simple VBScript or JavaScript validation on the fields.....
here is an example, copy this code onto a page and then just take which bits you need and change the field names:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="VBScript">
sub CheckField1()
if document.form1.txt1.value = "" then
alert("You must enter details in field 1 first"
document.form1.txt2.value = ""
document.form1.txt1.focus
end if
end sub
sub CheckField2()
if document.form1.txt2.value = "" then
alert("You must enter details in field 2 first"
document.form1.txt3.value = ""
document.form1.txt2.focus
end if
end sub
</script>
</head>
<body>
<form name="form1" method="post" action="">
<table width="100%" border="0">
<tr>
<td><div align="right">First Field</div></td>
<td><input name="txt1" type="text" id="txt1"></td>
</tr>
<tr>
<td><div align="right">Second Field</div></td>
<td><input name="txt2" type="text" id="txt2" onBlur="checkfield1()"></td>
</tr>
<tr>
<td><div align="right">Third Field</div></td>
<td><input name="txt3" type="text" id="txt3" onBlur="checkfield2()"></td>
</tr>
</table>
</form>
</body>
</html>
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting
here is an example, copy this code onto a page and then just take which bits you need and change the field names:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="VBScript">
sub CheckField1()
if document.form1.txt1.value = "" then
alert("You must enter details in field 1 first"

document.form1.txt2.value = ""
document.form1.txt1.focus
end if
end sub
sub CheckField2()
if document.form1.txt2.value = "" then
alert("You must enter details in field 2 first"

document.form1.txt3.value = ""
document.form1.txt2.focus
end if
end sub
</script>
</head>
<body>
<form name="form1" method="post" action="">
<table width="100%" border="0">
<tr>
<td><div align="right">First Field</div></td>
<td><input name="txt1" type="text" id="txt1"></td>
</tr>
<tr>
<td><div align="right">Second Field</div></td>
<td><input name="txt2" type="text" id="txt2" onBlur="checkfield1()"></td>
</tr>
<tr>
<td><div align="right">Third Field</div></td>
<td><input name="txt3" type="text" id="txt3" onBlur="checkfield2()"></td>
</tr>
</table>
</form>
</body>
</html>
Regards
Vince
Visit my home: www.chez-vince.com
VBScript | ASP | HTML | SQL | Oracle | Hosting