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
- <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 />
Expand|Select|Wrap|Line Numbers
- 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."