Results 1 to 3 of 3

Thread: Input Validation

  1. #1
    Join Date
    Aug 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Input Validation

    I need to validate a second input in a form from another text input.

    I want Input_2 to have a popup alert saying that it needs to be filled out if text input_1 gets an entry in the form. If text input_1 has no entry then there will be no alert for text input_2.

    I hope this will be a function inside of a form validation.

    Thanks in advance.

  2. #2
    Join Date
    Mar 2011
    Posts
    2,144
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    What type of input is Input_2?

  3. #3
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Well, you'll have to post some code for us to be able to get in detail with this, but this should get you started:

    Code:
    function validateFrm() {
    input1 = document.getElementById('input_1');
    input2 = document.getElementById('input_2');
    
    if(input1.value != '') {
    if(input2.value == '') {
    alert('Please fill out input 2');
    }
    }
    The on the onsubmit event in your form, have it invoke the function validateFrm().
    - Josh

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
  •