Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I need help to perform required field validations in ASP script.

Eg:

Username ..........
Password ..........

In this , if the username and password are blanc ,I should display the error messages
"Enter your username" and "Enter yor password".

Since ASP script, the syntax are quite difficult .
Kindly provide suggestions.
Posted

Google reveals all:

Required Field Validator Tutorial[^]
 
Share this answer
 
Comments
maestro_88 31-Aug-11 6:14am    
Thanks for your response John. But I asked for ASP and not ASP.NET
#realJSOP 31-Aug-11 8:54am    
There is no such thing in legacy ASP. You have to write all that code yourself.
I suggest you that either use Javascript for validation or submit the form after form reolad check if values are blank display message.
 
Share this answer
 
JavaScript
function validateForm()
{
var x=document.forms["myForm"]["username"].value;
var y=document.forms["myForm"]["password"].value;
if (x==null || x=="")
  {
  alert("Enter Username");
  return false;
  }
if (y==null || y=="")
  {
  alert("Enter Password");
  return false;
  }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900