1 Attachment(s)
Re: Login Form using javascript
Hi
2. And this is the form code see attached
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/
Re: Login Form using javascript
Quote:
Originally Posted by
the_cat
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
Re: Login Form using javascript
Thank you for the examples.
Re: Login Form using javascript