469,626 Members | 1,025 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

check form

Hi

In this code the field must have at least 3 characters : (var minLength =
3;)
Code:
// check for Voornaam
if (document.Registreren.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.
Dec 9 '05 #1
1 1447
Yammaski wrote on 09 dec 2005 in comp.lang.javascript:
In this code the field must have at least 3 characters : (var
minLength = 3;)
Code:
// check for Voornaam
if (document.Registreren.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.


Not empty is the same as at least 1 char!

var minLength = 1;

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

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

<form onsubmit='return voornaamNietLeeg(this)'>
<input name='Voornaam'>
....

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

Dec 9 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Edward | last post: by
5 posts views Thread by Steve Wylie | last post: by
5 posts views Thread by rob willaar | last post: by
1 post views Thread by scprosportsman | last post: by
14 posts views Thread by Řrjan Langbakk | last post: by
5 posts views Thread by Andrew Meador | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.