|
I'm trying to do a little work for my buddies site, and teach myself JS at the same time. Running into a snag though with one little form. Basic set up of the form is like this: Enter Username:_______ (which is checked by if/else if for correct length) Enter Email: ________ Verify Email: _______ Not having any problem with the username, but rather with verifying the email addy. I know ill have to create a function and then i'm assuming if statements where Email = verify email. But i'm not exactly sure how to start it. I've tried googleing it, but not luck. If someone could give me a quick example of something like this i'd appreciate it. in case this makes a diff, here is the code of the username verification function checkInput(usernameId) { var usernameValue = document.getElementById(usernameId).value; alert("username is : " + usernameValue); if (usernameValue.length < 4) { alert("the username is too short"); } else if (usernameValue.length > 8) { alert ("the username is too long"); } else { alert("the username is ok"); } Sointenly fucked around with this message at 18:55 on Oct 11, 2009 |
# ¿ Oct 11, 2009 18:53 |
|
|
# ¿ May 3, 2024 19:25 |
|
Word, ill deff look into that. but i'd still like to know how to just code that out as is, it seems like it should be pretty simple... and i'd just like to know for my own knowledge.
|
# ¿ Oct 11, 2009 19:01 |
|
actually, all im really concerned with right now is making sure that the two emails that are entered are the same. after the username is entered, and the email is entered twice, the user presses a submit button which tests everything against the constraints. i know it may sound kind of counter productive... but all i need to know how to do is once the button is clicked, to check and see if both emails match... not really worried about the format of the email addy at this time.
|
# ¿ Oct 11, 2009 21:49 |
|
golgo13sf posted:
Sick, thank you! one last thing though, this is my HTML for the button used in the form... i initially wrote it to do the username verification. <input type="button" value ="checkIt" onclick = "checkInput('username');" /> do i need to make any changes to the html so that it will check email as well? thank you Sointenly fucked around with this message at 22:34 on Oct 11, 2009 |
# ¿ Oct 11, 2009 22:27 |
|
Im sorry, i don't mean to ask you to code my entire page... im still having problems linking everything together. Let me just show you everything i'm working with and maybe you can show me how to put everything together. Doing everything in Visual Studio, I have an HTML file and a JS file. The HTML for the structure of the input boxes and the check button is: code:
code:
|
# ¿ Oct 12, 2009 07:21 |
|
acht! can you spot where I'm loving up here HTML code:
code:
Sointenly fucked around with this message at 01:28 on Oct 13, 2009 |
# ¿ Oct 13, 2009 01:26 |
|
golgo13sf posted:
he wants all of the JS done via external file, does much change if i move everything out of the HTML?
|
# ¿ Oct 13, 2009 02:38 |
|
Sointenly posted:he wants all of the JS done in an external file and then linked, does much change if i move everything out of the HTML and into a separate .JS file?
|
# ¿ Oct 13, 2009 02:40 |
|
golgo13sf posted:Nope. Just for clarification sake... In the code you posted above, what is it that links those functions to the submit/verification button? Im used to VB where you just code everything individually using common names. I cant seem to find the connection here.
|
# ¿ Oct 13, 2009 03:57 |
|
golgo13sf posted:Nope. First of all, thank you very much for all the help. Everything is working with the exception of one little bug. If both email fields are left blank, it will alert the user to enter an email, but then it also alerts the user that inputs were accepted (because it then goes on to check that email1==email2 and i assume it accepts two blank fields as being == ) code:
|
# ¿ Oct 13, 2009 19:19 |
|
|
# ¿ May 3, 2024 19:25 |
|
quote:"return <value>" ceases all execution of that function and returns that value, kind of like an "exit function" statement in VB, except it returns a value. So you have a bunch of statements that return false on error and at the very end have a "return true;", if it gets to that point everything is ok and processing should continue. success! thank you
|
# ¿ Oct 13, 2009 20:23 |