By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,293 Members | 1,397 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,293 IT Pros & Developers. It's quick & easy.

client side javascript validation in ASP form,

100+
P: 114

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
Share this Question
Share on Google+
1 Reply


100+
P: 114
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

Post your reply

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