Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Any sugguest for java script check form
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Forum LockedAny sugguest for java script check form

 Post Reply Post Reply
Author
asp_beginner View Drop Down
Newbie
Newbie


Joined: 04 February 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote asp_beginner Quote  Post ReplyReply Direct Link To This Post Topic: Any sugguest for java script check form
    Posted: 04 February 2005 at 3:13pm
Tongue
Is any one can help me to make a javascript check form to check any input on WEB WIZ Rich Editor.
 
I'am using ver 3
 
Thank You,
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2005 at 3:30pm
heres a javascript form from this page.


<script language="JavaScript">
function CheckForm() {
 var errorMsg = '';

//For Gecko Madis API (RTE)
if (document.frmAddMessage.message.value.indexOf('<br>') > -1 && document.frmAddMessage.message.value.length == 8) document.frmAddMessage.message.value = '';


//Check for message
if (document.frmAddMessage.message.value==''){
errorMsg += '\n\tMessage Box \t\t- Enter a Message to Submit';
}

//If there is aproblem with the form then display an error
if (errorMsg != ''){
msg = '_______________________________________________________________\n\n';
msg += 'The form has not been submitted because there are problem(s) with the form.\n';
msg += 'Please correct the problem(s) and re-submit the form.\n';
msg += '_______________________________________________________________\n\n';
msg += 'The following field(s) need to be corrected: -\n';

errorMsg += alert(msg + errorMsg + '\n\n');
return false;
}

document.frmAddMessage.Submit.disabled=true;
return true;
}
</script>



just change the names for the form (frmAddMessage) and make sure the name for the message field (message) in the above example is correct.



Edited by dj air - 04 February 2005 at 3:30pm
Back to Top
asp_beginner View Drop Down
Newbie
Newbie


Joined: 04 February 2005
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote asp_beginner Quote  Post ReplyReply Direct Link To This Post Posted: 05 February 2005 at 11:06pm
Hi,
 
I can't make it work.
 Can anyone help to make a form check
 
this is the page
 
*******************************************
 
<html>
<head>
<title>Web Wiz Rich Text Editor</title>
<!--#include file="RTE_configuration/browser_page_encoding_inc.asp" -->
<!--//
/* *******************************************************
Application: Web Wiz Rich Text Editor
Author: Bruce Corkhill
Info: http://www.richtexteditor.org
Available FREE: http://www.richtexteditor.org
Copyright: Bruce Corkhill ©2002-2005
******************************************************* */
//-->
<meta name="description" content="Web Wiz Rich Text Editor, free WYSIWYG Eeditor for replacement of HTML text areas.">
</head>
<body bgcolor="#FFFFFF" text="#000000" OnLoad="initialiseWebWizRTE();">
 
 <div align="center" class="heading"><strong>Web Wiz Rich Text Editor</strong>
  <br />
  <br />
  <table width="680"  border="0" cellpadding="1" cellspacing="1" bgcolor="#666666">
  <tr>
    <td align="center" bgcolor="E6E7F2">    
    
    
    
      <form name="myForm" method="post" action="display_form_submission.asp">
     
     
     
<%
'----------------------------------------------------------------------------------------------
'The following onload event needs to be placed into the body tag for the web page you
'are placing the RTE into to initialise the Javascript for the Web Wiz Rich Text Editor (RTE):-
'OnLoad="initialiseWebWizRTE();"

'The following needs to be placed on the line above the textarea that you wish to be
'replaced with the Web Wiz Rich Text Editor (RTE).
'----------------------------------------------------------------------------------------------

Dim strFormName
Dim strTextAreaName
'Edit the intilised variables below to put in the name of your textrea's ID and the name
'of the form the textarea is within
'Name of the HTML form the textarea is within
strFormName = "myForm"
'ID tag name of HTML textarea being replaced
strTextAreaName = "myTextarea"
'----------------------------------------------------------------------------------------------
%>
<!-- include the Web Wiz Rich Text Editor -->
<!--#include file="RTE_editor_inc.asp" -->
        <textarea name="textarea" cols="80" rows="15" id="myTextarea">
&lt;!-- Pre-filled textarea content --&gt;
&lt;br&gt;   
&lt;div style="text-align: center; font-family:arial,helvetica,sans-serif;"&gt;
&lt;h2&gt;Welcome to Web Wiz Rich Text Editor&lt;/h2&gt; Free replacement WYSIWYG Editor for your textareas
&lt;img alt="Thumbs Up" src="images/smiley20.gif" align="middle"border="0"&gt;
&lt;br&gt;
&lt;br&gt;
More information and free download available from &lt;a href="http://www.webwiz.net"&gt;&lt;/a&gt;
&lt;a href="http://www.richtexteditor.org"&gt;www.richtexteditor.org&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
Copyright 2002-2005 &lt;a href="http://www.webwiz.net"&gt;Web Wiz Guide&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/div&gt;
       
        </textarea>
           
       
       
        <br />
        <br />
        <input type="submit" name="Submit" value="Submit Form">
        <input name="reset" type="reset" value="Reset Form">
        <br />
       
       
      </form>
     
   </td>
  </tr>
</table>
<%
'***** START WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
If blnAbout Then
 Response.Write("<br /><span class=""text"" style=""font-size:10px"">Powered by <a href=""http://www.richtexteditor.org"" target=""_blank"" style=""font-size:10px"">Web Wiz Rich Text Editor</a> version " & strRTEversion)
 Response.Write("<br />Copyright &copy;2002-2005 <a href=""http://www.webwiz.net"" target=""_blank"" style=""font-size:10px"">Web Wiz Guide</a></span>")
End If
'***** END WARNING - REMOVAL OR MODIFICATION OF THIS CODE WILL VIOLATE THE LICENSE AGREEMENT ******
%>
</div>
</body>
</html>
Back to Top
stafford View Drop Down
Newbie
Newbie


Joined: 05 February 2005
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote stafford Quote  Post ReplyReply Direct Link To This Post Posted: 05 March 2005 at 11:55pm
Using the js and form shown below The validation Alert shows correctly but when OKing the alert the form submits to the next page. If the RTE isn't installed and only a text box is used  the validation works perfectly.   I do see that it works on the board here, am I missing  something simple?

<script  language="JavaScript">
<!-- Hide from older browsers...

//Function to check form is filled in correctly before submitting
function CheckForm () {
   
    var errorMsg = "";
   
    //Check for an News Title
    if (document.frmNews.title.value==""){
        errorMsg += "\n\tTitle \t\t- Enter a title for the News Item";
    }
   
    //Check for an News Title
    if (document.frmNews.shortNews.value==""){
        errorMsg += "\n\tShort News \t- Enter a Short News Item to display";
    }
   
    //Check for news Item
    if (document.frmNews.newsItem.value==""){
        errorMsg += "\n\tNews Item \t- Enter a News Item to post";
    }
   
    //If there is a problem with the form then display an error
    if (errorMsg != ""){
        msg = "____________________________________________________________________\n\n";
        msg += "Your News Item has not been submitted because there are problem(s) with the form.\n";
        msg += "Please correct the problem(s) and re-submit the form.\n";
        msg += "____________________________________________________________________\n\n";
        msg += "The following field(s) need to be corrected: -\n";
       
        errorMsg += alert(msg + errorMsg + "\n\n");
                return false;
    }

    document.frmNews.Submit.disabled=true;
    return true;
}
// -->
</script>


and this form:

<form method=post name="frmNews" action="WWN_add_news.asp" onSubmit="return CheckForm();" onReset="return ResetForm();">
        <table width="660" border="0" cellspacing="0" cellpadding="1" bgcolor="#000000" height="230" align="center">
          <tr>
            <td height="66" width="967"><table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF" height="201">
                <tr>
                &n bsp; <td height="199"><table width="100%" border="0" align="center" height="191">
                &n bsp;     <tr>
                &n bsp;       <td colspan="2" height="30" class="text" align="left">*Indicates required fields</td>
                &n bsp;     </tr>
                &n bsp;     <tr bgcolor="#FFFFFF" >
                &n bsp;       <td align="right" width="20%" height="12">News Title*:</td>
                &n bsp;       <td height="12" width="80%"><input type="text" name="title" size="30" maxlength="50">
                &n bsp;       </td>
                &n bsp;     </tr>
                &n bsp;     <tr>
                &n bsp;       <td valign="top" align="right" height="22">Short News Item*:</td>
                &n bsp;       <td height="22" valign="bottom">
                             <textarea name="shortNews" cols="57" rows="5" id="shortNews"></textarea>
                        </td>
                &n bsp;     </tr>
                &n bsp;     <tr >
                &n bsp;       <td height="61" colspan="2" align="right" valign="top" ><span class="text">News Item*
                &n bsp;       :</span><br>
                       
                                <%
            '------------------------------------------------------------------------------- ---------------
           
            'The following onload event needs to be placed into the body tag for the web page you
            'are placing the RTE into to initialise the Javascript for the Web Wiz Rich Text Editor (RTE):-
           
            'OnLoad="initialiseWebWizRTE();"
           
           
            'The following needs to be placed on the line above the textarea that you wish to be
            'replaced with the Web Wiz Rich Text Editor (RTE).
     
Back to Top
frasmus View Drop Down
Newbie
Newbie


Joined: 20 March 2005
Location: United States
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote frasmus Quote  Post ReplyReply Direct Link To This Post Posted: 20 March 2005 at 7:04pm
Hi, I think my situation is nearly identical to Stafford's.
 
My text area has the following JS check within the same page as the RTE component:
 
 var descr = oform.P5.value
 oform.P5.value = descr
 if (descr == "") {
  var errorm = errorm + ("    -- Description is required.    \n");
  var trap = ("error");

 }
 
The page submits normally when using the standard text area but when using RTE it sees a zero length string.
 
The RTE is fabulous. Is there something simple I can do? I'm really stuck! Confused
 
 
Back to Top
stafford View Drop Down
Newbie
Newbie


Joined: 05 February 2005
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote stafford Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2005 at 9:42am
frasmus
Good luck. I worked for a while on  it with resolution to the problem. It was easier in the end to let the form submit and do the verification with asp on the next page.  It works here so there is probably a simple solution. Not one that I could see though
Back to Top
4u2ges View Drop Down
Newbie
Newbie


Joined: 25 April 2005
Location: United States
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote 4u2ges Quote  Post ReplyReply Direct Link To This Post Posted: 25 April 2005 at 8:31pm
Originally posted by frasmus frasmus wrote:

Hi, I think my situation is nearly identical to Stafford's.
 
My text area has the following JS check within the same page as the RTE component:
 
 var descr = oform.P5.value
 oform.P5.value = descr
 if (descr == "") {
  var errorm = errorm + ("    -- Description is required.    \n");
  var trap = ("error");

 }
 
The page submits normally when using the standard text area but when using RTE it sees a zero length string.
 
The RTE is fabulous. Is there something simple I can do? I'm really stuck! Confused
 
 
 
 
NOTE: This is for RC only
 
add a hidden form after the <textarea>:
 
<input type="hidden" id="descr" name="descr">
 
 
In JS in place of:
 
 var descr = oform.P5.value
 oform.P5.value = descr
 
insert:
 
 <% If RTEenabled() <> "false" then
   Response.Write "document.getElementById('descr').value = document.getElementById('WebWizRTE').contentWindow.document.body.innerHTML;"
   Response.Write "var descr = document.getElementById('descr').value;" & vbcrLf
   Response.Write "if (descr.indexOf('<br>') > -1 && descr.length == 8) {var descr=''}"  & vbcrLf
  Else
   Response.Write "var descr = oform.P5.value;"
  End If
 %>
 
 
 
 
 
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.