File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes onclick event(alert) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "onclick event(alert)" Watch "onclick event(alert)" New topic
Author

onclick event(alert)

padmshree Patil
Ranch Hand

Joined: Dec 18, 2000
Posts: 54
Hi,
I have one longin page(Login.html)
Here I am validating for entry in LID and PW field.
After entering login id and PW it is going to Login.java Servlet
But problem is
When user doesn't enter LID or PW ,I am showing alert and set ing focus to
that filed.
if( document.forms[0].LId.value =="" &&
document.for[0].PW.value =="" )
{
alert( "you must enter valid Id and Password " )
document.forms[0].LId.focus()
}
this code is on validate function.
and clling this as
<INPUT TYPE="SUBMIT" VALUE="Login" onclick = 'validate( this )'>
it woking fine but when I add
<FORM ACTION="http://localhost:8100/servlet/Login" METHOD="POST">
After alert it directly goes to Servlet
What I have do???
Thanks,
padmasshree
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
Instead of having an onClick that runs the function, have an onSubmit = validate(this) in your FORM tag. Then in your function, make sure you return false; if you do not want to submit the form, and return true; if they entered the values correctly and you do want to submit the form.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: onclick event(alert)
 
Similar Threads
onclick event(alert)
Java Script problem
Javascript not executing in WSAD test server
HTTP status 500
Prevent the page refreshing