473,466 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

form validation

anfetienne
424 Contributor
is there a way to check if all form fields are filled in? i can do it singular but just need to know if it can be done
Apr 29 '09 #1
8 1108
pronerd
392 Recognized Expert Contributor
@anfetienne
Yes. There are thousands of examples of JavaScript form validation available. Just Google for "JavaScript +form +validation".
Apr 29 '09 #2
anfetienne
424 Contributor
i have a form validation method that i learned already....i cant find if its possible to validate a form as a whole rather than checking if a field is filled out?
Apr 29 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
Yes, you can. Check the links in the Offsite Links sticky. The basic idea is to validate all the elements of the form one by one onsubmit:
Expand|Select|Wrap|Line Numbers
  1. <form ... onsubmit="return validate()">
Apr 29 '09 #4
anfetienne
424 Contributor
i think im going about this the wrong way.....is it possible for javascript to do this i.e. say if the form returns no errors then do something else?
Apr 29 '09 #5
anfetienne
424 Contributor
ok ive done the validation.....is there a way i can get a value thats in javascript into a php.....i want to get the value that goes into obj2 into a php var......is it possible?

Expand|Select|Wrap|Line Numbers
  1. <script>
  2.   function CopyValue(obj1, obj2)
  3.   {
  4.      var visibleField = obj1;
  5.      obj2.value = visibleField.value;
  6.   }
  7. </script>
  8.  
Apr 29 '09 #6
acoder
16,027 Recognized Expert Moderator MVP
Yes, either pass it through the URL:
Expand|Select|Wrap|Line Numbers
  1. location.href="file.php?var="+encodeURIComponent(jsvar);
or set a hidden field value in the form to the variable value:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("hidden").value = jsvar;
Note:encodeURIComponent() encodes the value in case there are any special characters.
Apr 30 '09 #7
anfetienne
424 Contributor
does this do so without having to go to another page or refresh?
Apr 30 '09 #8
acoder
16,027 Recognized Expert Moderator MVP
Yes, but if you want to avoid that, use Ajax.
Apr 30 '09 #9

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

Similar topics

17
by: Phil Powell | last post by:
Where can I find an online PHP form validator script library to use? I have tried hacking the one here at work for weeks now and it's getting more and more impossible to customize, especially now...
4
by: TG | last post by:
I have a validation form that must behave differently based on the results of a PHP validation check. I have a post command at the top of my form that calls itself. I don't leave the form when...
4
by: bnp | last post by:
Hi All, I am quite new the JavaScript. Basically I am a C++ programmer, but now I am working on JavaScript since last 5 days. I have a problem regarding the form validation. I have created a...
16
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
9
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
27
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
10
by: gweasel | last post by:
What is the best way to apply a Validation Rule - or rather, where is the best place to put it? Is there an advantage to putting it on the field in the table vs setting the validation rule on the...
5
by: lucyh3h | last post by:
Hi, I am trying to use XMLHttpRequest to do server side validation. I have several fields on a form and a submit button. The submit button has an event assocated with it when clicked. The...
7
ak1dnar
by: ak1dnar | last post by:
Hi, I got this scripts from this URL There is Error when i submit the form. Line: 54 Error: 'document.getElementbyID(....)' is null or not an object What is this error. Complete Files
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.