2 Replies - 1816 Views - Last Post: 06 June 2002 - 12:31 AM

#1 kaizix   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 12-March 02

Javascript - Validation (kinda)

Posted 05 June 2002 - 11:27 PM

does anyone know how i could use javascript to make an alert msg appear if, say, in a form, a text field isn't filled in but a certain checkbox is checked?
Is This A Good Question/Topic? 0
  • +

Replies To: Javascript - Validation (kinda)

#2 SlashRaid   User is offline

  • Dream.In.Force

Reputation: 1
  • View blog
  • Posts: 2,421
  • Joined: 21-January 02

Re: Javascript - Validation (kinda)

Posted 06 June 2002 - 12:02 AM

B) I have two really great ones for you. Check'em out and see if they will be of any help.Here is an excellent example code you may want to use for reference:
<HTML>
<HEAD>
</HEAD>
<BODY>
<script LANGUAGE="Javascript">
<!--
function valid(form) {
  var field = form.age;  
  var userAge = parseInt(field.value);   
  if (!userAge) {
    alert("You must indicate your age.");
    return false;
  } else if (userAge >= 21) {  
      alert("Thank your for your comments.");  
      return true;
    } else {
        alert("You are only " + userAge + ". Try again when you are 21."); 
        field.focus();
        field.select();
        return false;
      }
}
// -->
</SCRIPT>

<FORM METHOD="POST"
      ACTION="mailto:[email protected]"
      ENCTYPE="text/plain"
      onsubmit="return valid(this)">
Your age:<BR><INPUT TYPE="text" NAME="age" SIZE="2"><BR>
Field of Study:<BR><INPUT TYPE="text" NAME="study" SIZE="40"><BR>
Comments:<BR><TEXTAREA NAME="comments" COLS="40" ROWS="5"></TEXTAREA><BR>
<INPUT TYPE="submit" VALUE="Submit Commnets">
</FORM>
</BODY>
</HTML>


You should be able to use something similar. ;)
Was This Post Helpful? 0
  • +
  • -

#3 kaizix   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 12-March 02

Re: Javascript - Validation (kinda)

Posted 06 June 2002 - 12:31 AM

thanks...i've done some searching and found a different way to do it.... i found a script that disables the submit button and, using some validation, got it to do what i wanted.....that netscape page....way out of my league. thanks though.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1