473,395 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

onSubmit, run a javascript, return true or false

59
hello,

i want to check for errors on submitting a form, on encountering an error it runs a function and returns a false preventing form submit. I have implemented that.

Expand|Select|Wrap|Line Numbers
  1. function eCheck()
  2. {
  3.  var filePath = document.getElementsByName("fileSelect");
  4.  
  5.  if (filePath == '')
  6.  {
  7.   errorPath();
  8.   return false;
  9.  }
  10.  
  11.   return true;
  12. }
  13.  
Expand|Select|Wrap|Line Numbers
  1. <form action="process.php" method="post" onSubmit="return eCheck();">
  2.  
When i do the above, it isn't going through the check or rather not running the function errorPath(); and returning the value as false.

but when i do the following, errorPath(); works and form submit is called off.

Expand|Select|Wrap|Line Numbers
  1. <form action="process.php" method="post" onSubmit="errorPath(); return false;">
  2.  
but i want it to run the error check. Any ideas on way it's not working.

Thanks in Advance.
Jul 9 '07 #1
4 3662
acoder
16,027 Expert Mod 8TB
Can you show the code for errorPath().
Jul 10 '07 #2
cssExp
59
it only makes a div viable from hidden, nothing more is in it :)
Jul 10 '07 #3
gits
5,390 Expert Mod 4TB
Expand|Select|Wrap|Line Numbers
  1. var filePath = document.getElementsByName("fileSelect");
  2.  
  3. if (filePath == '') {
  4.     // do something
  5. }
  6.  
hi ...

filePath is a node-list the way you call it - so it will never be a single value ...

use getElementById or loop through the list, or refer element with index=0 or something like that ... and compare the VALUE ;)

kind regards
Jul 10 '07 #4
acoder
16,027 Expert Mod 8TB
filePath is a node-list the way you call it - so it will never be a single value ...
Oh, I missed that. I see what the OP tried to do. You should use getElementsByName for radio buttons and checkboxes to loop over them.
Jul 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
1
by: bbxrider | last post by:
the onreset is working but problem somewhere in the onsubmit or the function it calls. i have abbreviated the called verfiy function for now just to get the basic onsubmit part working basically...
2
by: OtisUsenet | last post by:
Hello, I am trying to call Javascript from FORM's onSubmit, and return false, so the form is not actually submitted. Normally I can just add 'return false;' to onSubmit to accomplish this, like...
2
by: Sean Dockery | last post by:
Which is the following is correct? a) <form ... onSubmit="return checkData()"> b) <form ... onSubmit="return checkData();"> c) <form ... onSubmit="checkData()"> d) <form ......
8
by: Chris Kettenbach | last post by:
I have a function that validates a text box. Is there anyway to run that function on submit and if it returns false to cancel the submit. Any ideas. Thanks Guys! This group is awesome. Thanks,...
2
by: tim | last post by:
Hello All, I have a problem I have not been able to resolve with a webbased project I am working on for work (not fun). The scenario is this: I have a search that can take quite some time...
5
by: plumba | last post by:
Hi all I have a form (see below), which for some reason has decided to stop functioning all together. It just does not call up the function. It is called up in the opening <form> tag but...
8
by: Mark Livingstone | last post by:
I have a form that uses the following: onSubmit="some_var = 'validated';" FireFox is OK with that. Internet Explorer isn't. any ideas why? Thanks.
2
by: rudiedirkx | last post by:
Gents, I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/answers/166542-onsubmit-safari but not as detailed as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.