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

facing problem while submitting

 
sen senk
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

in my program if i click on submit button with out selecting any values then error msg is displaying,this is fine,but my page is refreshing how to restrict this.

function OnSubmitForm()
{
if(document.getElementById('userName1').value==0)
{

document.getElementById('sucessMessage').style.visibility = 'visible';
document.getElementById('sucessMessage').style.color = 'red';
document.getElementById('sucessMessage').innerHTML="Please select the user";
timeMsg();
return false;

}
else if(selObj.length==0 && check==0)
{
document.getElementById('sucessMessage').style.visibility = 'visible';
document.getElementById('sucessMessage').style.color = 'red';
document.getElementById('sucessMessage').innerHTML="Please Map the KRI Indicators";
timeMsg();
return false;
}

}

function timeMsg()
{
var t=setTimeout("disappearMsg()",8000);
}

function disappearMsg()
{

document.getElementById('sucessMessage').style.visibility = 'hidden';

}
 
Akhilesh Trivedi
Ranch Hand
Posts: 1599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Ranch.

http://www.coderanch.com/how-to/java/CarefullyChooseOneForum
 
Gautam Velpula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried to return false; outside the if - else -if statement?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic