Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prevent the page refreshing

 
kavita vala
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a form and in that there are some fields .
When i was clicked on submit button javascript validation are applied on it
And if there is a field empty alert is displayed After that all form values are gone.
And form becomes blank.
How can i stop page refreshing automatically?

My javascript code is here



And html code is



Please help me for this issue.
 
Eswar Nec
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use return keyword like



 
kavita vala
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Eswara.
Its really working good.
 
kavita vala
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works for if some field is empty but in regular flow if
any user fill all the details then its not submit the value to the servlet
because i use return to the on click event .

If there is another way to stop refreshing if some fields are empty
and also my data will submit to servlet if all fields are filled.

Than please help me for that.
 
Eswar Nec
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kavita vala wrote:It works for if some field is empty but in regular flow if
any user fill all the details then its not submit the value to the servlet
because i use return to the on click event .
.


You mean , you can't receive the text filed value after use return keyword.
I think , Already you use the following code to pass text field value.

Then,
How to receive the text filed value?
Can you post that code here
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic