CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Join Date
    Feb 2019
    Posts
    10

    Re: Login Form using javascript

    Hi

    2. And this is the form code see attached
    Attached Images Attached Images  

  2. #17
    Join Date
    Jun 2009
    Posts
    113

    Re: Login Form using javascript

    Apart from the line:
    Code:
    var suffix="-remoteally.viewnetcam.com:40040";
    in the getURL() function missing a semi-colon at the end, I can't see any syntactic error in what you've done. I'm not familiar with require so cannot advise there as to when you can call jQuery document loaded functions.
    You can just go back to basics, and add an "onClick" event handler to your "Press Enter" button, like this:
    Code:
    <button onClick="validateLogin()" type="button">Press Enter</button>
    And then add a script block afterwards which does exactly the same thing as your jQuery based code, so create a function e.g. validateLogin() which does exactly the same thing - reads the text input field and concatenates it with your URL, checking for "blankness":
    Code:
    function validateLogin(){
    	var prefix = "http://";
    	var suffix = "-remoteally.viewnetcam.com:40040";
    	var username = document.getElementById("username");
    	var myURL = prefix + username.value + suffix;
    	if (username.value.replace(/ /g,'')!=='') {
    		window.location.href = myURL;
    	}
    	else {
    		username.parentElement.setAttribute("class","error");
    	}
    }
    Here's a JSFiddle which put this altogether with your CSS: https://jsfiddle.net/sz63vp2g/

  3. #18
    Join Date
    Feb 2019
    Posts
    10

    Re: Login Form using javascript

    Quote Originally Posted by the_cat View Post
    Apart from the line:
    Code:
    var suffix="-remoteally.viewnetcam.com:40040";
    in the getURL() function missing a semi-colon at the end, I can't see any syntactic error in what you've done. I'm not familiar with require so cannot advise there as to when you can call jQuery document loaded functions.
    You can just go back to basics, and add an "onClick" event handler to your "Press Enter" button, like this:
    Code:
    <button onClick="validateLogin()" type="button">Press Enter</button>
    And then add a script block afterwards which does exactly the same thing as your jQuery based code, so create a function e.g. validateLogin() which does exactly the same thing - reads the text input field and concatenates it with your URL, checking for "blankness":
    Code:
    function validateLogin(){
    	var prefix = "http://";
    	var suffix = "-remoteally.viewnetcam.com:40040";
    	var username = document.getElementById("username");
    	var myURL = prefix + username.value + suffix;
    	if (username.value.replace(/ /g,'')!=='') {
    		window.location.href = myURL;
    	}
    	else {
    		username.parentElement.setAttribute("class","error");
    	}
    }
    Here's a JSFiddle which put this altogether with your CSS: https://jsfiddle.net/sz63vp2g/

    Hi

    A Big thanks to you

    This is working now, i can now use the mouse to click instead of pressing the enter key. on my keyboard

    Thanks

  4. #19
    Join Date
    Feb 2020
    Posts
    5

    Re: Login Form using javascript

    Thank you for the examples.

  5. #20
    Join Date
    Feb 2020
    Posts
    5

    Re: Login Form using javascript

    Thanks for the samples

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured