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

Replies

  • Sahithi Pallavi
    Sahithi Pallavi
    Any help?
    #-Link-Snipped-# #-Link-Snipped-# #-Link-Snipped-# #-Link-Snipped-#
  • Anoop Kumar
    Anoop Kumar
    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 ๐Ÿ˜€
  • Sahithi Pallavi
    Sahithi Pallavi
    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 ๐Ÿ˜€
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Oyee!!! I assume that the form tag ends there. You had given right? You can do this way:
    
    
        
            
            Sada
            
            
        
     
        
            
                
      [*] [*] [*]
      Search Engine
      [*]
    โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹
  • Sahithi Pallavi
    Sahithi Pallavi
    #-Link-Snipped-# - Thank you so much, Your code is working good.
    And as #-Link-Snipped-# said I just called sub() in validate() so that no need to change my code.
    And let me know which one is efficient? ๐Ÿ˜›
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    Sada
    #-Link-Snipped-# - Thank you so much, Your code is working good.
    And as #-Link-Snipped-# 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?
  • Sahithi Pallavi
    Sahithi Pallavi
    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.
  • PraveenKumar Purushothaman
    PraveenKumar Purushothaman
    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...
  • Sahithi Pallavi
    Sahithi Pallavi
    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 ๐Ÿ‘

You are reading an archived discussion.

Related Posts

i have to choose between these two as a subject for my final year. i like embedded more and iam good at it too, but DIP seems interesting as well.....
i had completed my btech(ec) with 71% am i eligible for applying for mtech in international if yes then which country is more economical?
I need some suggestions regarding alternative material for a high pressure seamless gas cylinder. The present material of cylinder is Si-Mn Steel and is to be replaced by another lightweight...
Anybody heard about burnbit.com? I have a very slow internet connection and I downloaded a file around 800 MB. The power went of in between the download and finally the...
Hello fellow CEans, I need to design a LNA in a cascode topology in Cadence/ADS which is used in smart phones. Typically the LNA should be capable of processing the...