Submit button does not open a page WelocmeToTesting.html. Can someone please help here?
Login Page
UserId |
Submit button does not open a page WelocmeToTesting.html. Can someone please help here?
Login Page
UserId |
Not without seeing your code.
<html><head><title>Login Page</title><head>
<script language="JavaScript" type="text/JavaScript">
<!--//hide script
function checkme()
{
var _invalidChars = new Array("!","@");
var _str = document.f1.Uid.value;
var _chr = _str.charAt(1);
for(var i = 0; i < _str.length; i++)
{
_chr = _str.charAt(i);
for(var j = 0; j < _invalidChars.length; j++)
{
if(_chr == _invalidChars[j])
{
alert("You have entered an invalid character for User Id.");
return false
}
}
}
document.FrmId.submit()
return true;
}
// --->
</script></head><body><br>
<form name="f1" id="FrmId" action="./WelocmeToTesting.html" method="post">
<DIV align=center><table border="1" bgcolor="6A5ACD">
<tr><td><br>UserId<input name="Uid"><br><br>
<input type="button" value="Submit" name="Submit0" onClick="JavaScript:checkme()">
</td></tr></table></form></div></body></html>
I posted the code in java code format.
Thank you. I will remember it for next time…
Have you tried looking in the JS console for errors? That’s where I would start.
I just joined the forum and did not look into JS console yet. How do I go to JS console?
The code gives proper error message when user enters special character (! or @) but when user enters correct data then it does not open a page.
Google: “How to open browser console”
Thank you. I just checked in JS Console of chrome and found below error.
Uncaught TypeError: Cannot read property ‘submit’ of undefined
I am running this script from my C drive.
Correct, it is telling you that you are trying to call the method submit() on a value that is undefined. This is the line it is complaining about:
document.FrmId.submit()
So it is saying that document.FrmId
is undefined (i.e. it doesn’t exist). Your job is to figure out how to make this line work. My recommendation:
Google: “javascript form submit method”
Make sure you are using the submit method properly.
But From id has been already defined.
<form name="f1" id="FrmId" action="./WelocmeToTesting.html" method="post">
Yes, the form has an id. Now you need to access the form correctly using the id.
Google: “javascript access element by id”
Thank you for your guidance. I was able to resolve the issue.