View Feed
group-icon
Java Developers
Community of Java Developers: Get Java Programming Help from fellow Java Developers across the world.
623 Members
Join this group to post and comment.

JavaScript Problem for login form

I'm new to JavaScript and I'm facing a problem with simple User login form.
What I need is -

-> User should enter his username, password and his role and has to click submit. All fields are mandatory. And based on the user role, the appropriate login page of the user will be displayed and that should go with radio buttons.

I'm posting my code here, its not working properly. If I come in order by entering username, password, role, its working fine. If I click the radio button first and then clicked submit without entering username and password, I'm getting successful user display page.
Here is my JavaScript code.

 

Here is my HTML login form code.
User ID
Password:
Search Engine : User 1
User 2
User 3
Anoop Kumar
Anoop Kumar • Jun 15, 2012
If I click the radio button first and then clicked submit without entering username and password, I'm getting successful user display page.
here.
onclick="validate(login);sub();"
Call sub() in Validate function. not explicitly.
in your code, you are getting return false in Validate() but not in sub.
call sub() in Validate() as last line.
I think it will work 😀
ianoop
here.
onclick="validate(login);sub();"
Call sub() in Validate function. not explicitly.
in your code, you are getting return false in Validate() but not in sub.
call sub() in Validate() as last line.
I think it will work 😀
ha ha Thank God sorry thank you. It was solved now.
How foolish thing I did? 😔
Anyway I got to know one type of problem and its solution, once again, thanks 😀
Oyee!!! I assume that the form tag ends there. You had given right? You can do this way:


    
        
        Sada
        
        
    
 
    
        
            
    [*] [*] [*]
    Search Engine
    [*]
​​​​​​​​​​​​​​​​
Praveen-Kumar - Thank you so much, Your code is working good.
And as ianoop said I just called sub() in validate() so that no need to change my code.
And let me know which one is efficient? 😛
Sada
Praveen-Kumar - Thank you so much, Your code is working good.
And as ianoop said I just called sub() in validate() so that no need to change my code.
And let me know which one is efficient? 😛
Actually, both are good programmatically. But UI wise, mine would be a better and semantic option. Agree?
Praveen-Kumar
Actually, both are good programmatically. But UI wise, mine would be a better and semantic option. Agree?
Any justification? 😛
Sorry I'm new to Javascript.
Sada
Any justification? 😛
Sorry I'm new to Javascript.
Na! Nothing related to JavaScript. Just compare both the codes, see the structure, readability, etc. and lemme know your opinion...
Praveen-Kumar
Na! Nothing related to JavaScript. Just compare both the codes, see the structure, readability, etc. and lemme know your opinion...
Your code is good, no extra functions and all 👍

Share this content on your social channels -