/    Sign up×
Community /Pin to ProfileBookmark

Help a newbie please, help with form submission check.

Hello,

I know what I want to do is simple but I am having a hard time with it. I have an email form that I want to perform a check on. Basically if the checkbox at the end is not checked I want to alert and not submit but if it is checked than I want it to submit.

I’m sure it is a simple script but I am a PHP and PERL developer and I know very little about Javascript.

Any help you can give would be appreciated.

Thanks,

Buddy

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@steelersfan88Mar 22.2004 — [CODE]<form [attributes (whatever you already have here)] onsubmit="return checked('id of checkbox')>
<!-- Stuff Here -->
<input type="checkbox" id="the id here">
</form>[/CODE]
And then at the top of the page:[code=php]<script type="text/javascript>

function checked(nom) {
return (document.getElementById(nom).checked)
}

</script>[/code]
That should do it. If you want an alert:[code=php]<script type="text/javascript>

function checked(nom) {
if(!document.getElementById(nom).checked) {
alert("Not checked!")
return false;
}
return true;
}

</script>[/code]
Copy linkTweet thisAlerts:
@BuddyFintonauthorMar 22.2004 — It didn't seemed to work. Here is the code that I have:

<html>

<head>

<title>Credit Application</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script type="text/javascript>

function checked(nom) {

if(!document.getElementById(nom).checked) {

alert("Not checked!")

return false;

}

return true;

}

</script>

</head>

<body>

<!-- -->

<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#000000">

<tr>

<td bgcolor="#FFFFFF"><div align="center">

<p><font size="6" face="Arial, Helvetica, sans-serif">Credit Application</font></p>

<form action="/cgi-sys/cgiemail/loan_app.txt" name="loanform" method="post" onSubmit="return checked(required-oath)">

.

.

.

.

<input name="required-oath" type="checkbox" id="required-oath" value="All statement made by we(us) in this application are true and correct and have been made by me(us) in order to induce you to grant credit to me(us). I(we) understand that consumer reports may be requested from consumer reporting agencies in connection with this application. I(we) authorize you to view our consumer credit report.I(we) authorize Southeast Financial to exchange credit information with others in connection with this application.">

can you see what the problem is?

Thanks for your help,

Buddy
Copy linkTweet thisAlerts:
@steelersfan88Mar 22.2004 — [CODE]onSubmit="return checked([COLOR=red]'[/COLOR]required-oath[COLOR=red]'[/COLOR])">[/CODE]That should work!
×

Success!

Help @BuddyFinton 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.27,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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