View Full Version : 1ly receive filled form fields??
Membie
11-13-2002, 09:15 PM
I've got a form with many inputfields. I only wish to receive the filled ones, not the blanc ones, not the matching left blanc field names. Now i receive all the fields, even if only one field is filled.
Has to be html / client side scripting (sorry).
Any help, tnkx in adv. ;)
Ps Did search, didn't find the right answer ;) Searched wrong?
beetle
11-13-2002, 09:35 PM
This should do it. Not debugged :Dfunction disableBlanks(f) {
for (var i=0; i<f.elements.length; i++) {
var e = f.elements[i];
if (!/input|textarea/i.test(e.nodeName)) break;
if (/checkbox|radio/i.test(e.type)) break;
if (!/\S/.test(e.value)) e.disabled = true;
}
}
<form onSubmit="return disableBlanks(this);">
Membie
11-13-2002, 10:52 PM
Originally posted by beetle
...Not debugged
That's my problem I quess :D but help would be very nice, for I am NOT able to debug (JS learner he). Tried severall things, none of them worked properly :(
It concerns the attached file
Hope you can help. To the benifit of others aswell, I'm sure ;)
attachement delitted ;)
beetle
11-14-2002, 12:06 AM
I'll sit down and test this later, but for now I did notice 1 big error in my first post...function disableBlanks(f) {
for (var i=0; i<f.elements.length; i++) {
var e = f.elements[i];
if (!/input|textarea/i.test(e.nodeName)) break;
if (/checkbox|radio/i.test(e.type)) break;
if (!/\S/.test(e.value)) e.disabled = true;
}
return true;
}
<form onSubmit="return disableBlanks(this);">
whammy
11-14-2002, 12:13 AM
Hmm, that's cool.
I knew disabled fields weren't posted... but I never "made the connection" to a client-side form (enctype="text/plain"), since I never use that now that I use server-side scripting, and when I DID use client-side form posts I didn't care about getting blank fields anyway, since with client-side scripting you can't format stuff the way you want and I always thought it was rather ugly.
Interesting little tidbit to know though. :)
Membie
11-14-2002, 12:28 AM
Thank you very much in advance for being so kind 'Beetle' ;)
Prior to your test I'm sorry to inform you that the 'return true' correction didn't do the trick either :(
Solving this problem means very much to me. Therefor I don't mind returning any favor any time, if I can ;) Promise to do my very best in advance ;)
Greetings, John ;)
whammy
11-14-2002, 12:36 AM
What browser are you using to test it in?
Membie
11-14-2002, 12:44 AM
IE 6.0 (windows XP) How could this be the problem, if / when it is???
Membie
11-14-2002, 10:04 PM
This thread / my problem is rapidly going to the 3 page (and on). Please forgive me but...
Originally posted by beetle
I'll sit down and test this later...
Any 'luck' sofar? :(
No bold :D or rude intensions, just a (in case...) 'reminder'
John
beetle
11-14-2002, 10:58 PM
Ok, I tested this version...it only disables empty input (text and password) fields and textareasfunction disableBlanks(f) {
for (var i=0; i<f.elements.length; i++) {
var e = f.elements[i];
if (!/input|textarea/i.test(e.nodeName)) continue;
if (e.nodeName == "INPUT" && !/text|password/i.test(e.type)) continue;
if (!/\S/.test(e.value)) e.disabled = true;
}
return false;
}
whammy
11-15-2002, 12:47 AM
I don't know how much time you have, Membie, but if you really want to manipulate forms and user data, etc., I'd learn a server-side language if I were you (i.e. PHP, ASP, ASP.NET, Perl, etc.)!
HTML and Javascript just don't give you enough options if you're concerned about data itself - and it looks like you're at the stage where those options are exactly what you're looking for, judging by this post. :)
Javascript will always be used for webpages though as it's the default client-side scripting language, and it does things that server-side scripting languages cannot accomplish, since they are two different things.
Membie
11-15-2002, 08:36 AM
Thanks for all your help Beetle :thumbsup:
Whammy you're absolutely right but the problem is that serverside scripting has to be provider supported.
Dutch providers in generall do offer this support, but then again charge for it. Customers in generall, want to be first rang but unknowingly choose an account that doesn't match their needs. Rather then changing the account they want all possibilities checked first. "I've heard that..., told that..., etc., etc". Unknowingly again not letting the account choice to the 'designer'... :(
Hope to live to see the day that serverside scripting support is common good / logicall provider choise for all customers. But then again for now there's another group, the ones that cannot have the server side scripting provider support because they aren't in business. In my country that's a condition for those full hosting possibilities (you have to be business registrated for that)
I'll just inform my 'customer' (my brother in this case) he has better possibilities when changing his account. Pay for it or deal with it ;) NOT: "Going Dutch"--> :D
Greetings and till next time?
whammy
11-15-2002, 11:46 PM
Yup, you do have to pay for good server-side support. But one thing, always make sure you know (as much as possible) what the customer wants up front, and if they are using anything that is going to require databases, make sure they know it up front. You're the expert, not the customer. :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.