How do I create a text field that requires people to confirm their email address?
-
I have seen this on websites I have used in the past (it seems to be used mostly for passwords, when they ask you to enter your password twice, and if they don't match, it won't let you submit the form). So how can I do the same thing for an email address? This is the code I have so far, I have already created two fields (Email Address) and (Confirm Email Address). <span id="sprytextfield1">Email Address <input type="text" name="text1" id="text1" /> <span class="textfieldRequiredMsg">Please enter an email address.</span></span><span id="sprytextfield4">Confirm Email Address <input type="text" name="text4" id="text4" /> <span class="textfieldRequiredMsg">A value is required. What code do I need to make the form only submit when both email addresses match? Thank you for any help.
-
Answer:
The whole process of password or mail would bi similar. You have a form which onsubmit calls a Javascript function with return value to validate your form. If the form is valid (in this case both emails match) the function will return true and form submit, if not it won't do anything. <form action="example.php" onsubmit="return validate_form()"> <input type="text" id="mail1" /> <input type="text" id="mail2" /> <!-- rest of your elements --> </form> and the Javascript part: <script type="text/javascript"> function validate_form() { var str1 = document.getElementById("mail1").value; //here you can check whether str1 is a valid email var str2 = document.getElementById("mail2").value; if(str1 != "" && str1 == str2) return true; else return false //and here you can create warning so the user knows what's wrong that form won't submit } </script>
Daniel Abbott at Yahoo! Answers Visit the source
Other answers
You would need a Javascript code to read the individual key inputs of the second string and compare it to the first, maybe hiding the submit button until they match. Far better to allow subkit, passing both entries as post variables, with from cal to PHP_SELF and use an if() statement to compare them, then show itself again with both entries filled in if they do not match This way you can also verify that the entries are in legitimate email address format rather than risking a script attack from a hacker.
Colinc
you could google form validation, there's lots of free validation scripts and tutorials out there, but since it looks like you're already using validation with Spry then you will need this.. http://labs.adobe.com/technologies/spry/articles/confirm_overview/index.html
Related Q & A:
- How do I create a new Yahoo address name?Best solution by Yahoo! Answers
- How can i send a text message through yahoo email?Best solution by Yahoo! Answers
- How do i create a new yahoo address?Best solution by Answerbag.com
- How can I get a text alert when I get an email?Best solution by Yahoo! Answers
- How do I send a text from email?Best solution by eHow old
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.