Evertjan.
9/29/2015 10:11:00 AM
Abdullah hasan <abdullahh546@gmail.com> wrote on 29 Sep 2015 in
comp.lang.javascript:
> On Tuesday, September 29, 2015 at 4:19:41 PM UTC+8, Abdullah hasan
> wrote:
>> On Tuesday, September 29, 2015 at 5:44:14 AM UTC+8, Evertjan. wrote:
>> > abdullahh546@gmail.com wrote on 28 Sep 2015 in comp.lang.javascript:
>> >
>> > > I am creating a Registration/login page . When user enter a field ,
>> > > and goes no to next field , i want the browser to show the error
>> > > just below the incorrect data field . In this way only valid
>> > > entries is submitted . I dont want to show error when user click
>> > > submit button . Just after every wrong field when going to next
>> > > field .
>> >
>> > Have you got a question?
>> >
>> > Is this a school assignment?
[please do not quote signatures on usenet]
>> No assignment . Just experimenting . I can easily show the error(if
>> any) below the field when user hit submit button . But what i want is
>> to show error immediately after going to next field .
>
> function myfunction() {
> var v = document.getElementById('email').value;
> if(v=="") {
> document.getElementById('colour1').className+=' has-error';
> document.getElementById('fill').innerHTML =
> 'Please enter a valid username';
> return false;
Not needed for below.
> };
> };
[Still my first Q is not anwered, I'll have to guess]
use:
<input onBlur = 'myfunction(this)' ...>
For multiple fields getElementById() will not be ideal,
try DOM-transversing with:
'this', 'parentNode', etc.
and display:none or visibility:hidden.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)