This is an email form on an ASP page. I want to add validation before it submits, The current validation only checks "name, email, and content" (server side) if the spaces are empty. I need to add the following so that the form is not submitted unless the following is true.
1. The "name" field must be maximum 20 characters. Not left empty. Letters only.
2. The "email" must be a valid email. Not left empty.
3. The "subject" must be maximum 50 characters.
4. The "content" must be maximum 4000 characters. Not left empty.
Would it be better if i also added client side javascript validation too? if so what do i add? Thanks in advance for any help. Below is the email form page - <% Dim ID, RS, SQL, NAME, EMAIL, COMMENT, sDATE, IO, M_ID, SUBJECT, CITY, COUNTRY, ALLOW_E, AID, NEXT_ID, C_NAME, C_EMAIL, MESSAGE, _
-
blDONE, blLOGGED_IN
-
-
ID = Trim(Request.QueryString("ID"))
-
AID = Trim(Request.QueryString("AID"))
-
IF IS_VALID_ID(ID) = False OR IS_VALID_ID(AID) = False THEN Response.END
-
MODE = Request.Form("mode")
-
-
IF Trim(Session("PMMS_IN")) = "True" THEN blLOGGED_IN = True
-
-
IF MODE = "send" THEN
-
-
NAME = Request.Form("name")
-
EMAIL = Request.Form("email")
-
CONTENT = Request.Form("content")
-
SUBJECT = Request.Form("subject")
-
-
-
-
-
Call GET_DETAILS()
-
-
-
IF NAME = "" OR IsNull(NAME) THEN MESSAGE = MESSAGE & "<li />Please enter your name.<br />"
-
IF EMAIL = "" OR IsNull(EMAIL) THEN MESSAGE = MESSAGE & "<li />Please enter your email address.<br />"
-
IF CONTENT = "" OR IsNull(CONTENT) THEN MESSAGE = MESSAGE & "<li />Please enter your message.<br />"
-
-
IF MESSAGE = "" THEN
-
CONTENT = CONTENT & vbcrlf & vbclrf & _
-
-
Call SEND_EMAIL_OUT(CONTENT, SUBJECT, C_EMAIL, EMAIL, "smtp.myweb.com")
-
-
blDONE = True
-
-
'Response.Redirect "_comment_view.asp?ID=" & ID & "&AID=" & AID
-
'Response.END
-
-
END IF
-
-
-
ELSE
-
-
Call GET_DETAILS()
-
NAME = Session("PMMS_NAME")
-
EMAIL = Session("PMMS_EMAIL")
-
-
END IF
-
-
-
-
SUB GET_DETAILS()
-
SQL = "SELECT fldNAME, fldEMAIL, fldCOMMENT, fldDATE, fldIP, fldM_ID, fldCITY, fldCOUNTRY, fldALLOW FROM nm_tbl_comment WHERE ID = " & ID
-
Call OPEN_DB()
-
-
Set RS = Server.CreateObject("ADODB.Recordset")
-
RS.LockType = 1
-
RS.CursorType = 0
-
RS.Open SQL, MyConn
-
IF NOT RS.EOF THEN
-
C_NAME = trim(RS("fldNAME"))
-
C_EMAIL = trim(RS("fldEMAIL"))
-
ALLOW_E = trim(RS("fldALLOW"))
-
-
END IF
-
RS.Close
-
Set RS = Nothing
-
-
MyConn.Close
-
Set MyConn = Nothing
-
END SUB
-
-
-
%>
-
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
<html><head>
-
-
</head><body bgcolor="#ffffff">
-
-
<body style="overflow:hidden;">
-
-
<%IF blDONE = True THEN%>
-
-
<table width="100%" height="100%" align="top" cellpadding="2" cellspacing="0" border="0"><tr>
-
<div style="width:100%;height:100%;overflow:auto"' border=0>
-
<td align="left" valign="top">
-
<span class="style1">Thank you. Your email has been sent. </span></td>
-
</div>
-
-
<td align="right" valign="bottom"><a href="javascript:window.close();" class="style1"><img src="comment_imgs/e_close.gif" width="47" height="12" alt="" border="0" /></a></td>
-
</tr></table>
-
-
<%Response.END%>
-
<%END IF%>
-
-
<%IF NOT MESSAGE = "" THEN%>
-
<table width="95%" height="70" border="0" align="center" cellpadding="2" cellspacing="0">
-
<tr>
-
<td><%=MESSAGE%></td>
-
</tr></table>
-
<br />
-
<%END IF%>
-
<span class="style1"></td>
-
</tr>
-
</table>
-
</span>
-
<form action="?ID=<%=ID%>&AID=<%=AID%>" method="post">
-
<table cellpadding="2" cellspacing="0" border="0" width="95%" align="center"><tr>
-
<td colspan="2" class="style1">Send email to: <span style="color:#dd4800;"><strong><%=C_NAME%></strong></span></td>
-
</tr><tr>
-
<td>Your Name:</td>
-
<td><input style="width: 335px;" type="Text" name="name" value="" maxlength="180" class="textbox" /></td>
-
</tr><tr>
-
<td>Your Email:</td>
-
<td><input style="width: 335px;" type="Text" name="email" value="" maxlength="180" class="textbox" /></td>
-
</tr><tr>
-
-
<td>Subject:</td>
-
<td><input style="width: 335px;" type="Text" name="subject" value="<%=SUBJECT%>" maxlength="180" class="textbox" /></td>
-
</tr><tr>
-
<td colspan="2"><textarea class="textbox" rows="15" name="content" style="width: 100%;"><%=CONTENT%></textarea></td>
-
</tr><tr>
-
<td colspan="2"><br /><input type="Submit" value="Send Email" /></td>
-
</tr></table>
-
-
<input type="Hidden" name="mode" value="send" />
-
-
</form>
-
-
-
<p> </p>
0 1334 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: bnp |
last post by:
Hi All,
I am quite new the JavaScript. Basically I am a C++ programmer, but
now I am working on JavaScript since last 5 days.
I have a problem regarding the form validation.
I have created a script that validates the form fields. the validation
procedure is called ONCLICK event of the submit button.
Follwowing is the structure of the validation procedure.
|
by: julie.siebel |
last post by:
Hello all!
As embarrassing as it is to admit this, I've been designing db driven
websites using javascript and vbscript for about 6-7 years now, and I
am *horrible* at form validation.
To be honest I usually hire someone to do it for me, grab predone
scripts and kind of hack out the parts that I need, or just do very
minimal validation (e.g. this is numeric, this is alpha-numeric, etc.)
|
by: Chris |
last post by:
Hi,
I have a form for uploading documents and inserting the data into a mysql
db. I would like to validate the form. I have tried a couple of Javascript
form validation functions, but it appears that the data goes straight to the
processing page, rather than the javascript seeing if data is missing and
popping up an alert. I thought it may be because much of the form is
populated with data from the db (lists, etc.), but when I leave...
|
by: lucyh3h |
last post by:
Hi,
I am trying to use XMLHttpRequest to do server side validation.
I have several fields on a form and a submit button. The submit button
has an event assocated with it when clicked. The javascript method
will do the form validation for each field one by one.
For each field, an XMLHttpRequst will be made to a PHP file and get
the return, either set an error field (<span>'s innerHTML) or leave it
empty.
Then I'll check the error field...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |