# Help with ASP

**URL:** <https://forum.kirupa.com/t/help-with-asp/12229>\
**Category:** programming\
**Created:** [January 28, 2003, 5:58pm UTC](https://forum.kirupa.com/t/help-with-asp/12229 "2003-01-28T17:58:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![evader](https://avatars.discourse-cdn.com/v4/letter/e/e9a140/32.png) [@evader](https://forum.kirupa.com/u/evader)\
**Post date:** [January 28, 2003, 5:58pm UTC](https://forum.kirupa.com/t/help-with-asp/12229/1 "2003-01-28T17:58:35Z")

</div>

I have created a guestbook using ASP in Dreamweaver MX. Now I want to make a couple of the text forms on the submit page maditory. For example: I have a spot for the visitor to enter their name, email address and their location. What I want to do is make it so the name and email parts of it are required before the message can be posted.

I’ve seen it a bunch of times when you fill out forms online, there’s a little red \* beside the fields that are required…

Can anybody help me out here?

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 28, 2003, 6:17pm UTC](https://forum.kirupa.com/t/help-with-asp/12229/2 "2003-01-28T18:17:58Z")

</div>

I don’t know any asp, check google for asp tutorials and I’m sure you’ll find something. I’m sure you just need to use an IF statement or something like that. 🙂 sorry I can’t help more. I am an ASP moron. I:-)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 28, 2003, 7:26pm UTC](https://forum.kirupa.com/t/help-with-asp/12229/3 "2003-01-28T19:26:52Z")

</div>

```php

<html>
<title></title>
<body bgcolor="#FFFFFF">
<% 
' Checks to see if the user inputted a value
' If so, remove leading and trailing blanks and upcase it
u_email= ucase(trim(request.form("u_email"))) 

' Grab the length of the email address inputted
email_len=len(u_email)

' if the user has inputted a value start checking it
if trim(u_email) <> "" then 

' Loop that will check each character of the inputted value
' for the @ and the dot
for counter = 1 to email_len 
'If there is an @ set u_at to the position it was found in 
if mid(u_email,counter,1)="@" then 

' count the number of @'s
at_counter=at_counter+1

' if there is more than one add it to the message
if at_counter > 1 then message = message &"There appear to be multiple @'s in the email address<br>" end if

' if this is the 1st @ note the location in the string
if u_at = "" then
u_at=counter
end if ' end check for first @
end if ' end check for the @ 

'If there is an dot (.) set u_dot to the position it was found in
if mid(u_email,counter,1)="." then 
if u_dot = "" then
u_dot=counter
end if 'end check for the first dot 
end if 'end check for the dot 

next 

' Check to see if the dot comes after the @
' and that the first dot is not the last character
if (u_dot < u_at) or (len(u_email) <= u_dot+1) or ((u_dot-u_at) < 2) or (u_at < 2)then
message = message & "Email convention appears to be wrong <br>"
end if 'end check for dot after the @

' Scan the user input to see that all inputted values are either a letter A-Z,
' a number 0-9 or if the character is a . or and @.
for counter=1 to len(u_email)  
if (mid(u_email,counter,1) <> "/") and ((mid(u_email,counter,1) > chr(45)) and (mid(u_email,counter,1) < chr(58))) or ((mid(u_email,counter,1) > chr(63)) and (mid(u_email,counter,1) < chr(91))) then
else
' If it's an invalid charcter add it to the display message
message = message & "Invalid charcter "& mid(u_email,counter,1)& " found in email address <br>"
end if 'end check for invalid characters  
next 'end loop for invalid characters
end if 'end check for user input

' If the email address os not OK than display the message(s)
' and show the text box for user input with the last value pre-filled
if message <> "" or u_email = "" then
response.write message %>
<form action="<%= request.servervariables("script_name") %>" method="post">
Enter your email address<br>
<input type="text" name="u_email" value="<%= lcase(u_email) %>">
<input type=submit value=Submit>
<%
' If the email address is ok display it or
' add another process to hereafter
else 
response.write lcase(u_email) & " seems ok" 
end if %>

```

I dont remember where i get this code from, its an email validator. i think its old… havent check it in a while… try it out

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 28, 2003, 7:27pm UTC](https://forum.kirupa.com/t/help-with-asp/12229/4 "2003-01-28T19:27:24Z")

</div>

its very explanatory 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 29, 2003, 1:55am UTC](https://forum.kirupa.com/t/help-with-asp/12229/5 "2003-01-29T01:55:08Z")

</div>

You can use ASP to do server-side form validation, but it is much more efficient to use javascript to do the form validation client-side BEFORE the data is sent to the server for processing. Faster for the user, and less load on the server.

Dreamweaver has a built in form validation behavior, but I prefer the one written by Yaromat. I find it more robust and easier to use. You can download it free at:

[http://www.yaromat.com/dw/?t=Behavior&r=validation](http://www.yaromat.com/dw/?t=Behavior&r=validation)
