37 users online (1 members and 36 guests)  

Thread: js validate


  Results 1 to 3 of 3

Related

  1. Replies: 9
  2. Replies: 2
  3. Validate Drop Down Menu    Forum: Javascript Forum
    Replies: 5
  4. Validate Question    Forum: HTML Forum
    Replies: 4
  1. #1
    f&m's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    4

    js validate

    hi,
    i'm looking validate script for....(document.insert.location1.checked == false) {
    document.insert.student1.style.visibility = "hidden";
    else {
    document.insert.student1.style.visibility = "";

    i want "student1" to be validated , only if i click on location1,

    i tryed this script but , it checks "student1 ", before i click on "location1"

    if(document.insert.location1.cheked!="")
    {

    document.insert.student1.value!="";
    }

    else { alert("student1 is not filled");}
    Last edited by f&m; 02-04-2005 at 03:14 AM.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi, welcome to the forum.

    You need to put this script into an event, the event being theform being submitted.

    First, make your code a function so it can be called at any time:

    Code:
    function check_loc1() {
    
    if (document.insert.location1.checked) {
    
    if (document.insert.student1.value=='') {
    alert('Student1 is not filled');
    return false;
    }
    
    return true;
    }
    return true;
    }
    In your <form> tag, add

    Code:
    onsubmit="return check_loc1();"
    I haven't checked the code but you get the idea.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    f&m's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    4
    hi, thnx , it works



Tags for this Thread