DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2007
    Posts
    42

    client side javascript validation in ASP form,


    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.


    Code:
    <table align="center" width="400" cellpadding="2" cellspacing="0" border="0">
    										<form action="_comments.asp?ID=<%=NID%>" method="post" name="frm3" id="frm3" onSubmit="return ValidateComment()">
    										<tr>
    											<td width="100">Name</td>
    											<td width="300"><%=Session("PMMS_USERNAME")%></td>
    										</tr><tr>
    											<td>Country</td>
    											<td width="300"><%=Session("PMMS_COUNTRY")%></td>
    										</tr><tr>
    											<td>Subject*</td>
    											<td width="300"><input type="Text" name="subject" value="" maxlength="50" class="textbox" style="width: 100%"></td>
    										</tr><tr>
    										
    										
    										
    										
    					<%
    
    	'Declare the ASP variables used
    	Dim strFormName
    	Dim strTextAreaName
    	
    	'ID tag name of the HTML form the textarea is within
    	strFormName = "frm3"
    	
    	'ID tag name of HTML textarea being replaced
    	strTextAreaName = "comment"
    	
    	%>							
    							
    	
    	
    		
    		<td valign="top">Comment*</td>
    											<td width="300">	<!-- include the  Rich Text Editor -->
    	<!--#include file="richtext_editor_inc.asp" -->	<textarea name="comment" id="comment" rows="6" cols="50"  style="width: 100%;" class="textbox"></textarea>
    											
    	
    
    							
    											<input type="Checkbox" name="allowE" value="1" />Allow readers to email me.
    											</td>
    										</tr><tr>
    											<td></td>
    											<td><input type="Submit" value="Leave Comment" /></td>
    										</tr>
    										<input type="Hidden" name="mode" value="set" /></form>
    										</table>
    										<br /><br />
    and i think this is the server side validation.

    Code:
    		IF SUBJECT = "" Or IsNUll(SUBJECT) THEN MESSAGE = MESSAGE & "<li />Please enter a subject."
                IF COMMENT = "" Or IsNUll(COMMENT) THEN MESSAGE = MESSAGE & "<li />Please enter your comments."
                IF IsEmailValid(EMAIL) = False THEN MESSAGE = MESSAGE & "<li />Please enter a valid email address."

  2. #2
    Join Date
    Jun 2004
    Location
    Pakistan
    Posts
    292
    see if this helps: http://www.codetoad.com/javascript/isempty.asp
    Create a function (lets say its mysubmit) for your onSubmit for the form tag, and then call the valdiation function for each value from your mysubmit function.
    new to programming but getting ther

Similar Threads

  1. Form validation form.length
    By braveheartkenya in forum Web
    Replies: 0
    Last Post: 10-04-2006, 10:46 PM
  2. Replies: 0
    Last Post: 08-31-2006, 07:02 PM
  3. How to handle client side events in javascript
    By SangeetSwapna in forum Web
    Replies: 1
    Last Post: 02-28-2006, 03:48 AM
  4. Replies: 3
    Last Post: 06-16-2000, 03:51 PM
  5. Replies: 0
    Last Post: 06-01-2000, 06:39 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links