• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Prevent the page refreshing

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use return keyword like



 
kavita vala
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic