Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alert without refreshing the page

Status
Not open for further replies.

Ross1811

MIS
Oct 1, 2004
122
US
Is there anyway to return to a page with refreshing it? Right now I have a condition to check if subject ="" if it is i have a javascript alert. But the only problem is that it refreshes the page, --> the other required fields that the user might have filled out are now emptied. Is there a way around this????? I am checking on submit,

Thanks,
Ross



<script language="javascript">
alert("Please define subject")
</script>
 
<script language="javascript">
function AlertSubject()
{
alert("Please define subject");
}
</script>


At the submit button add last: onClick="AlertSubject()"



Right?
 
Ouppsss... something is missing:

Code:
<script language="javascript">
  function AlertSubject()
  {
    if (textboxSubject.getText=="")
      alert("Please define subject");
  }
</script>

At the submit button add last: onClick="AlertSubject()"


Now should be ok.
 
you want to return false.

simplified example:

Code:
<script language="javascript"><!--

function validate() {
    if (document.forms['formName'].elements['subject'].value == '') {
        alert("Please enter a subject!");
        return false;
    }
}

//-->

Code:
<form ... onsubmit="return validate();">

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top