/    Sign up×
Community /Pin to ProfileBookmark

email validation, order totals, and properly naming forms.

Hi, I am taking a class in ‘web programming’. I am 35 woman, and I’m in a team of 22 year olds. We have a project with javascript, obviously. I find searching the internet for help to be a bit overwhelming. I will post individual segments of the project that I have done… most of it is still just html, but we’re supposed to use functions, etc, to make it do stuff. Trying to copy from what we learned in class isn’t working out.

First, the submit button with the command to validate an email address:

<input type=’button’ value=’submit’ onclick=’validate()’
<script>
function validate(){
email=document.biostuff.email.value;
posAt=emailindexof(“@”);
if (posAt==-1){
alert(‘Bad email’);
return;
};
</script>

so I have the function

email=document.biostuff.email.value;

I used:
<input type=hidden…. tags to name the profile form not ‘document’.

So not only do I need help with the function itself, I need to know how I was supposed name the form so that my javascript finds it.

Oh in addition…. I would like someone to explain the ‘alert’ command. In class we used it in html with the input tag and now it’s here in the javascript. Let me know if that also needs corrected.

One more question about this example, is where do I place it in the textfile? In the form, before the form, by the submit button?

Thank you. I will be posting more questions in this thread.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@mityaSep 22.2009 — Sorry to say it but it's hard to help here in some of the questions because your grasp of the terminology is not overly strong. For example, your function is actually a variable declaration. By textfile I assume you mean a field. Etc.

We've seen several people on here asking for help with courses that seem not to teach things as they should.

For example, you wouldn't normally reference a field via document.something.something, but either

document.forms[0].field

or, more commonly

document.getElementById('myfield') (meaning you need to give the element an ID tag).

As for the alert function, this is a built-in JS function which simply puts out a message in a box. It's one of 3 dialogue boxes, which interrupt the flow of script and demand the user's attention. It's considered obtrusive these days and is only really used for debugging.

I would strongly suggest reading up on the basics of variables, functions and forms in order to your task.
Copy linkTweet thisAlerts:
@opifexSep 22.2009 — @phyrebrand - may I ask what textbook is being used in this course? I remember seeing an "assignment" very similar to this on a different forum about a year ago... the course was based on original [U]Netscape JavaScript Handbook[/U] from around 1996.... and was flavored for Netscape browser capabilities during the early years of the browser wars.
×

Success!

Help @phyrebrand 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.18,
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,
)...