check form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yammaski

    check form

    Hi

    In this code the field must have at least 3 characters : (var minLength =
    3;)
    Code:
    // check for Voornaam
    if (document.Regis treren.Voornaam .value.length < minLength) {
    alert('You have to fill in at least 3 characters');
    return false;
    }

    I want to chance the code, so that they have to fill in something, it may
    not stay empty.

    Regards,
    Yammaski.


  • Evertjan.

    #2
    Re: check form

    Yammaski wrote on 09 dec 2005 in comp.lang.javas cript:
    [color=blue]
    > In this code the field must have at least 3 characters : (var
    > minLength = 3;)
    > Code:
    > // check for Voornaam
    > if (document.Regis treren.Voornaam .value.length < minLength) {
    > alert('You have to fill in at least 3 characters');
    > return false;
    > }
    >
    > I want to chance the code, so that they have to fill in something, it
    > may not stay empty.
    >[/color]

    Not empty is the same as at least 1 char!

    var minLength = 1;

    function voornaamNietLee g(x){
    if (x.Voornaam.val ue.length < minLength) {
    alert('You have to fill in at least '+minLength+' character[s]');
    return false;
    }
    return true;
    }

    ...............

    <form onsubmit='retur n voornaamNietLee g(this)'>
    <input name='Voornaam' >
    ....

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)

    Comment

    Working...