473,320 Members | 1,926 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

client side javascript validation in ASP form,

114 100+

I have a comment form, on a news website, ASP page, which users fill in and it adds comments to a news article. The reader clicks on a headline and the comments open up in a new window. It already has server side validation in but i want to add some client side javascript validation. How can do i this when there is alreay a "returnvalidate comment()" in? The only two fields i want to validate are "subject" and "comment" since the rest are drawn from the database. Any help would be appreciated, i'm not html or javascript or ASP literate. Thanks in advance.

This is what i want in the javascript client side validation: A pop up message should alert if the following is not the case,


Subject should be minimum 1 character and maximum 50 characters. Not left empty

Comment should be minimum 1 character and maximum 4000 characters. Not left empty.

Expand|Select|Wrap|Line Numbers
  1.         <table align="center" width="400" cellpadding="2" cellspacing="0" border="0">
  2.                                         <form action="_comments.asp?ID=<%=NID%>" method="post" name="frm3" id="frm3" onSubmit="return ValidateComment()">
  3.                                         <tr>
  4.                                             <td width="100">Name</td>
  5.                                             <td width="300"><%=Session("PMMS_USERNAME")%></td>
  6.                                         </tr><tr>
  7.                                             <td>Country</td>
  8.                                             <td width="300"><%=Session("PMMS_COUNTRY")%></td>
  9.                                         </tr><tr>
  10.                                             <td>Subject*</td>
  11.                                             <td width="300"><input type="Text" name="subject" value="" maxlength="50" class="textbox" style="width: 100%"></td>
  12.                                         </tr><tr>
  13.  
  14.  
  15.  
  16.  
  17.                     <%
  18.  
  19.     'Declare the ASP variables used
  20.     Dim strFormName
  21.     Dim strTextAreaName
  22.  
  23.     'ID tag name of the HTML form the textarea is within
  24.     strFormName = "frm3"
  25.  
  26.     'ID tag name of HTML textarea being replaced
  27.     strTextAreaName = "comment"
  28.  
  29.     %>                            
  30.  
  31.  
  32.  
  33.  
  34.         <td valign="top">Comment*</td>
  35.                                             <td width="300">    <!-- include the  Rich Text Editor -->
  36.     <!--#include file="richtext_editor_inc.asp" -->    <textarea name="comment" id="comment" rows="6" cols="50"  style="width: 100%;" class="textbox"></textarea>
  37.  
  38.  
  39.  
  40.  
  41.                                             <input type="Checkbox" name="allowE" value="1" />Allow readers to email me.
  42.                                             </td>
  43.                                         </tr><tr>
  44.                                             <td></td>
  45.                                             <td><input type="Submit" value="Leave Comment" /></td>
  46.                                         </tr>
  47.                                         <input type="Hidden" name="mode" value="set" /></form>
  48.                                         </table>
  49.                                         <br /><br />        
and i think this is the server side validation.

Expand|Select|Wrap|Line Numbers
  1.         IF SUBJECT = "" Or IsNUll(SUBJECT) THEN MESSAGE = MESSAGE & "<li />Please enter a subject."
  2.             IF COMMENT = "" Or IsNUll(COMMENT) THEN MESSAGE = MESSAGE & "<li />Please enter your comments."
  3.             IF IsEmailValid(EMAIL) = False THEN MESSAGE = MESSAGE & "<li />Please enter a valid email address."
Apr 25 '07 #1
1 1903
karen987
114 100+
Sorry i forgot to add that in addition to the above, the validation for the "subject" and "comment" should not allow "http://" in the body, a message should pop up telling them to remove "http://"

thanks in advance
Apr 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
5
by: Mong | last post by:
Hi, I have a webform with various asp controls on it such as textboxes and dropdownlists. I'm fairly new to asp.net coming from VB6 and am wondering when it's best to use client side events and...
1
by: rmgalante | last post by:
I have written an ASP.Net application that uses the standard client-side and server-side validation for various fields on the form. Some of the customers that use the form report symptoms that...
2
by: Wysiwyg | last post by:
I'm going back to a previous asp.net (C#) web project after a few months of inactivity and my first form, the login, won't submit. I ran with the debugger and still can't see how to resolve this. I...
5
by: Sun Jian | last post by:
Hi, I am trying to customize the asp.net validation to achieve the following: Upon submitting the form, client side validation will run, and it will stop at the first error detected. For...
0
by: Anthony W DiGrigoli | last post by:
I have two ASP.NET Server Side buttons that perform action on both the Server and Client side. Here is the break down of code placement: 1. Server-Side Load: Contains an Add Attribute for a...
1
by: vidya | last post by:
Hi, I have a button which is a web control. I have some validation in javascript for the button in .aspx file and some in the button onclick event in code behind(C#). I need to get through both...
3
by: Paul | last post by:
Hi all, I've been trying unsuccessfully to stop client side event validation. I've created a simple page with a text box, a required field validator and a server button with the following...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.