|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi guys!! i have another problem in my coding... how can i add an error checking in my page?? because i have a customer registration page where a customer will input items the page... how can i have an error checking in the page, just like having an error like "username should not be more than 12 characters" or to have an error checking account like "the password you have entered is not the same" because there will be a field with "password" and "re-type password..." thanks everyone!!!
-eeychi |
|
#2
|
|||
|
|||
|
You can use a client side event handler for validiation. Use the onsubmit event and check everything there. If you find an error, post an alert (or two) and cancel the event. You can also do server side validation but I don't like wasted trips to the server.
|
|
#3
|
|||
|
|||
|
Further to what trubolotta said, a little bit of JavaScript is your friend. Here's just a simple page with two password fields and a JavaScript validation function. Hopefully this will give you an idea of what you need to do for the rest of your fields.
![]() Code:
<html>
<head>
<title>JavaScript Form Validation</title>
<script language="JavaScript">
function checkPassword()
{
if(document.myform.txtpass.value==document.myform. txtconfirmpass.value)
{
alert("Your passwords match!");
return true;
}
else{
alert("Your passwords do not match! Please re-enter!");
return false;
}
}
</script>
</head>
<body>
<form name="myform" onsubmit="return checkPassword()" action="mypage.asp" method=post>
<b>Password:</b><br>
<input type=password name="txtpass"><br>
<b>Confirm Password</b><br>
<input type=password name="txtconfirmpass">
<br>
<input type=submit name="btnSubmit" value="Submit">
</form>
</body>
</html>
You can also get fancy and use regular expressions to check if a valid email address or phone number has been entered without having to bother the server with a request. ![]() |
|
#4
|
||||
|
||||
|
In asp:
Code:
If len(username) > 12 then
response.write("Username too long")
end if
|
|
#5
|
|||
|
|||
|
thanks 4 d help guys!!!
|
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > error checking in ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|