|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
argh...
can someone please tell me why, oh why does the page continue on when you click ok on the validation alert? It should just stay on the same page, let you fix ur field... ?? Code:
<script>
function validateForm() {
with (document.frmEnquiry) {
var alertMsg = "The following REQUIRED fields\nhave been left empty:\n";
if (from.value == "") alertMsg += "\nYour e-mail address.";
if (alertMsg != "The following REQUIRED fields\nhave been left empty:\n") {
alert(alertMsg);
return false;
} else {
return true;
}
} }
</script>
Code:
<input onmouseover="this.src='/images/submit_on.gif'" onmouseout="this.src='/images/submit.gif'" name="btnSubmit" type="image" onclick="validateForm()" value="Submit" src="/images/submit.gif" vspace="15" hspace="15" width="136" height="31" border="0"> |
|
#2
|
||||
|
||||
|
Example:
Code:
<script language="JavaScript">
function validateForm()
{
if (document.frmEnquiry.test.value =='')
{
alert("test is empty.");
return false;
}
return true;
}
</script>
<form name="frmEnquiry" onSubmit="return validateForm();" method="post">
<input type="text" name="test"><br>
<input onmouseover="this.src='/images/submit_on.gif'" onmouseout="this.src='/images/submit.gif'"
name="btnSubmit" type="image" value="Submit" src="/images/submit.gif" vspace="15" hspace="15" width="136" height="31" border="0"><br>
</form>
|
|
#3
|
|||
|
|||
|
cool. thanks Mem... you're a lifesaver... I figured out that the reason why my validations were doing this was becuase I didn't have
return validateForm() man, I need to take a JavaScript class or something... maybe I'll solicit suggestions from the forums... ![]() j |
|
#4
|
||||
|
||||
|
javascript is really not very complicated or spooky once you dive into its details... learn some C/C++ as it's based on those languages - doing this, you'll catch two birds in one action.
![]() |
|
#5
|
||||
|
||||
|
True.... almost
JavaScript was originally known as "LiveScript" (and officially known as "ECMAScript"), but Sun (who at the time had a say in Netscape's development) wanted to increase the hype about their Java platform by renaming the script standard as "JavaScript" as its syntax is losely based on Java itself with the fully-blown java language based on C++ but with modifications for cross-platform compliance </brief-history-lesson> HTH -1337_d00d |
|
#6
|
||||
|
||||
|
lol
you forgot <brief-history-lesson> starting tag, by the way... ![]() Now Sun has to pay billion green $$ for the Java... poor ppl ah? |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Freaking JavaScript! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|