/    Sign up×
Community /Pin to ProfileBookmark

Form validation issue

I have built a few form validation scripts, usually in the same context. For some reason, I can’t get this one to work. Firebug says “checkInput not defined”

[CODE]<script language=”javascript” type=”text/javascript”>

function checkInput(){
alert(“in here”); // check to see if it’s called
if(document.getElementById(‘sj_fname’).value == “First Name”){
alert(“You must enter your first name to continue”);
return false;
}else if(document.getElementById(‘sj_lname’).value == “Last Name”){
alert(“You must enter your last name to continue”);
return false;
}else if(document.getElementById(‘sj_email’).value == “Email”){
alert(“You must enter your email to continue”);
return false;
}else if(document.getElementById(‘sj_phone’).value == “Phone Number”){
alert(“You must enter your phone number to continue”);
return false;
}else if(document.getElementById(‘sj_addr’).value == “Address”){
alert(“You must enter your address to continue”);
return false;
}else if(document.getElementById(‘sj_city’).value == “City”){
alert(“You must enter your city to continue”);
return false;
}else if(document.getElementById(‘sj_zip’).value == “Zip”){
alert(“You must enter your zip code to continue”);
return false;
} else {
document.forms[0].submit();
return true;
}
}
</script>[/CODE]

then I have an image on the page, with this:

[code=html]<img src=”summerjam_submit.png” onclick=”return checkInput();” style=”cursor:pointer;” />[/code]

nothing is happening when I click the image.
it might be something stupid…it’s early though.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@monkee98Jul 14.2009 — try using a button with css to make it seem like an image + in some web browsers you will not be able to right click and save the image.

[code=html]
<input type="button" style="border-style: none; border-width: 0px; width: 100px; height: 100px; background-image: url('summerjam_submit.png');" onclick="checkInput()">
[/code]
×

Success!

Help @nbarone 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.28,
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,
)...