/    Sign up×
Community /Pin to ProfileBookmark

Validation Problem :(

hi all,

i havea script, which needs to validate that all fields have been filled in before the form validates.

if all the fields are valid i want a div layer to appear and the submit button to become disabled.

a link to the script is below, i cant see what i have done wrong ?
[url]http://www.bikerswebsite.com/script.txt[/url]

any help would be very very much apprechiated

thanks for any help
Anto

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinMay 16.2006 — is it only text fields that need to all be filled in?

if so, simply loop through the form element checking the element type and if it is a textbox make sure it has a value.

<i>
</i>for(i=0, e=''; i&lt;document.forms[formName].length; i++){
e = document.forms[formName].elements[i];
if(e.type == 'text' &amp;&amp; e.value.length &lt; 1){
alert('You must fill in the ' + e.name + ' box');
return false;
}
}


that's off the top of my head...I think it should work.
Copy linkTweet thisAlerts:
@CrazyMerlinMay 16.2006 — ok, so after the for loop add:

document.getElementsByNames('submit')[0].disabled=true;

roll('1');

and that should fix your problem
Copy linkTweet thisAlerts:
@AntoMUFCauthorMay 17.2006 — all thats left now is the showing of the div layer,

all forms get validated, and the submit button doesnt go disabled till ALL of the forms are correct ?

so, its just the div roll('1'); seems not to work ?
×

Success!

Help @AntoMUFC spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...