p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript How-To (http://p2p.wrox.com/forumdisplay.php?f=87)
-   -   validating rich text field for attachment (http://p2p.wrox.com/showthread.php?t=2831)

Mimi August 15th, 2003 03:02 AM

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[V]... Thanks!!!:D


natmaster August 16th, 2003 12:21 PM

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

Mimi August 20th, 2003 07:54 PM

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!


joefawcett August 21st, 2003 04:17 AM

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

Mimi August 25th, 2003 03:12 AM

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



All times are GMT -4. The time now is 06:16 AM.

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