Bitcoin Forum
August 16, 2024, 06:17:51 AM *
News: Latest Bitcoin Core release: 27.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: I want some very small html+js help  (Read 234 times)
SwingFirst (OP)
Hero Member
*****
Offline Offline

Activity: 678
Merit: 1000


View Profile
October 31, 2016, 07:47:50 PM
 #1

Hey all! Smiley

I have a contact form where the user has to enter his e-mail address.
I want to add another field where the user has to enter it again to verify, and if the input in the two fields doesn't match, the form won't send me an e-mail, and an alert will show where it tells the user to try again.

Here is how the form looks like at this moment:
Code:
<form id="contact_form" action="contact.php" method="POST" enctype="multipart/form-data">

        <label for="name">
          Name:
        </label><br />
        <input type="text" id="name" name="from" required><br />

        <label for="email">
          E-mail address:
        </label><br />
        <input type="text" id="email" name="email" required><br />

        <label for="message">
          Message
        </label><br />
        <input type="text" id="message" name="message" required><br />

        <input id="submit" type="submit" name="submit" value="Send" />

</form>

The form already works well, so there's no problem with that. As stated, I only want to add a second e-mail field and use javascript to check if the value in both fields match. I figure it's easy to do with very basic js skills, but I only have basic HTML skills. :p

Thank you for any help!
Radenz
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
October 31, 2016, 09:35:19 PM
 #2

I'm not very good at coding. But, i have learned a bit about coding.
I think you must use a string variable from js. And to verify, you can do with if condition. When email string and verify email string are same, then submit. When different, then show the alert.
Correct me if i'm wrong.
SwingFirst (OP)
Hero Member
*****
Offline Offline

Activity: 678
Merit: 1000


View Profile
October 31, 2016, 10:44:04 PM
 #3

I'm not very good at coding. But, i have learned a bit about coding.
I think you must use a string variable from js. And to verify, you can do with if condition. When email string and verify email string are same, then submit. When different, then show the alert.
Correct me if i'm wrong.
This is true, and you're not wrong. I just don't know enough javascript to actually put it to work. If you can help me practically, I would be grateful! Smiley
ZACHM
Hero Member
*****
Offline Offline

Activity: 777
Merit: 1003



View Profile
November 01, 2016, 03:40:50 AM
 #4

Here is a quick stab at it, let me know if it works for you.

Here is the Javascript function:

Code:
function emailVerify(contact_form) {
if (contact_form.email.value != contact_form.email_2.value)
{
alert('Your E-Mail addresses do NOT match!');
return false;
}
        else { return true; }
}

Here is the HTML with the extra parts added in.

Code:
<form id="contact_form" action="contact.php" method="POST" enctype="multipart/form-data" onsubmit="return emailVerify(this);">

        <label for="name">
          Name:
        </label><br />
        <input type="text" id="name" name="from" required><br />

        <label for="email">
          E-mail address:
        </label><br />
        <input type="text" id="email" name="email" required><br />

        <label for="email_2">
          Verify E-mail address:
        </label><br />
        <input type="text" id="email_2" name="email_2" required><br />

        <label for="message">
          Message
        </label><br />
        <input type="text" id="message" name="message" required><br />

        <input id="submit" type="submit" name="submit" value="Send" />

</form>
SwingFirst (OP)
Hero Member
*****
Offline Offline

Activity: 678
Merit: 1000


View Profile
November 01, 2016, 06:34:00 PM
 #5

Here is a quick stab at it, let me know if it works for you.

Here is the Javascript function:

-snip-

Thank you so much for this! I will try to integrate it to my website. Cheesy
diyajain
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
August 31, 2020, 07:47:57 AM
 #6

Numbers help to route the calls to the existing business numbers. This process starts with a virtual landline number initiating call via cloud server and route calls to the customer number and vice versa. Agents assigned with DID numbers can use these virtual numbers to place direct calls to customers. Businesses can apply DID numbers to route incoming calls to the assigned DID number agents. The incoming calls can be automatically answered via IVR with a personalised greeting before addressing the customer query. A sub-type of DID numbers are also available in the form of CLI (Caller Line Identification). This feature enables in initiating a fixed business number for all outgoing calls (C2C, OBD blast and OBD dialer)and incoming calls. DID numbers in India are available only on selected locations*

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!