Results 1 to 3 of 3

Thread: field comparison in javascript

  1. #1
    Join Date
    Sep 2009
    Location
    pakistan
    Posts
    28
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question field comparison in javascript

    HI
    Im using two field in HTML form 'emai' and 'ConfirmEmail'
    I want that when user submit the form both field values are get checked that user entered the same value in both fields .... How can i compare thsese two values using javascript......

    Feel free to email me from my profile.
    Last edited by jscheuer1; 12-21-2009 at 05:38 PM. Reason: Remove email address from open forum

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You really don't want to publish your email address in an open forum. You will get tons of spam.

    To answer your question, you need an onsubmit event for your form. About the simplest would be something like:

    Code:
    <form action="whatever" 
    onsubmit="if(this.elements.email.value === this.elements.ConfirmEmail.value){
    return true;
    }alert('Email and Confirm Email fields don\'t match');return false;">
    Insert the highlighted into your form tag.

    Notes: I used 'email' for the name of the email input. In your post you have it as 'emai'. But I'm thinking that was a typo. Whatever it's name is though, it should match up. Make sure that it does.

    Also, this will be of no use if the user has javascript disabled or unavailable. If you are processing the results of this form on the server side, a server side fall back should also be used.
    Last edited by jscheuer1; 12-22-2009 at 03:25 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2009
    Location
    pakistan
    Posts
    28
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Talking

    thanx alot ... that was email..

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •