onsubmit vs onclick

Results 1 to 2 of 2

Thread: onsubmit vs onclick

  1. #1
    Join Date
    Dec 1969

    Default onsubmit vs onclick

    I have this function which gives the alert when triggered &#039;onclick&#039; but not when using onsubit....can anyone see why?<BR><BR>Basically, if I leave it on click it presents the alert but then submits the page after it is cleared. So i need it ot presen the alert but then not submit the page.<BR><BR>function validateSelection()<BR>{ <BR> var needToAlert = false<BR> var strAlert = "Sorry! You can&#039;t submit the form yet:

    "<BR> var f = document.form1<BR><BR> if (f.selectedFile.value == &#039;&#039;)<BR> {<BR> needToAlert = true<BR> strAlert += "You haven&#039;t selected an image.

    "<BR> }<BR> if (needToAlert)<BR> {<BR> alert(strAlert)<BR> return false<BR> }<BR> else<BR> return true<BR>}<BR><BR>called using onsubmit="return validateSelection();"<BR>and<BR>onclick="validateS election()"

  2. #2
    Join Date
    Dec 1969

    Default RE: onsubmit vs onclick

    there&#039;s a tutorial on doing this stuff at http://www.infinitemonkeys.ws/ - it&#039;s quite elegant actually.<BR><BR>the code looks OK, but evidently there&#039;s *something* wrong

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts