Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2003, 03:02 AM
Authorized User
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Mimi
Default validating rich text field for attachment

Is it possible to validate a rich text field for attachments using javascript? If yes how? Please I've been working on this for more than 2 weeks already... Thanks!!!:D

 
Old August 16th, 2003, 12:21 PM
Authorized User
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to natmaster Send a message via AIM to natmaster Send a message via MSN to natmaster
Default

Yes!

Javascript:
validateForum() {
 if(document.forumName.inputName.value!="stuff") {
  alert('invalid entries');
 }
}

HTML:
<input type="submit" onClick="validateForum();">

----------------------------
Aeon of Darkness MUD - Free Online Roleplaying Game
http://aeonofdarkness.com
 
Old August 20th, 2003, 07:54 PM
Authorized User
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Mimi
Default

Thanks for the code! Unfortunately, it works even if only a string is in the rich text field and not an attachment. Is there a javascript code that specifically validates for attachment/s in a form? Thanks!

 
Old August 21st, 2003, 04:17 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't know what rich text fields are in relation to web pages. Do you mean if an input box of type equal to 'file' has a value in it? If so then:
Code:
<form name="frmUpload" onsubmit="validateForm();">
<input type="file" name="txtFile">
<input type="submit">
</form>
<script>
function validateForm()
{
  if (document.frmUpload.txtFile.value = "")
  {
    alert("You have not selected a file to upload.");
    return false;
  }
  return true;
}


</script>

--

Joe
 
Old August 25th, 2003, 03:12 AM
Authorized User
 
Join Date: Aug 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Mimi
Default

Thanks Joe! Yup, that was exactly what I needed.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Rich Text Features austinf Pro JSP 1 December 20th, 2006 03:47 AM
Validating textbox in field level Paula222 Access VBA 5 February 15th, 2006 11:57 AM
Rich Text Box spike010101 Pro VB 6 1 September 29th, 2004 02:37 AM
Validating a hidden field mkerchenski ASP.NET 1.0 and 1.1 Basics 1 June 3rd, 2004 11:20 AM
Validating a form field against a database microchip Classic ASP Basics 2 April 24th, 2004 04:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.