So am I actually supposed to write the script with the "function validate_numeric(myid);" or should I put in "function validate_numeric("companyAddress");" as the id of the field I am trying to validate is companyAddress? Also the second line "document.getElementById(myid)" should that be "document.getElementById("companyAddress")" as well?
EDIT: ok so I can't even get it to run the onclick event, i did something as simple as this...
Code: Select all
<head>
....
<script type='text/javascript'>
function mysubmit() {
alert("test");
}
</script>
</head>
<body>
....
<form id="frmCreate" name="frmCreate" method="post" action="send-mail.php">
<table>
<tr>
<td>Company Name</td>
<td><input type="text" name="companyName" id="companyName" tabindex="1" /></td>
</tr>
<tr>
<td>Company Address</td>
<td><input type="text" name="companyAddress" id="companyAddress" tabindex="2" /></td>
</tr>
<tr>
<td>Company Phone</td>
<td><input type="text" name="companyPhone" id="companyPhone" tabindex="3" size="10" maxlength="10" />
<br />
<span class="details">no spaces or dashes (eg, 6191230123)</span></td>
</tr>
<tr>
<td>Contact Name</td>
<td><input type="text" name="contactName" id="contactName" tabindex="4" /></td>
</tr>
<tr>
<td>Contact Phone</td>
<td><input type="text" name="contactPhone" id="contactPhone" tabindex="5" size="10" maxlength="10" /><br />
<span class="details">no spaces or dashes (eg, 6191230123)</span></td>
</tr>
<tr>
<td>Contact Email</td>
<td><input type="text" name="contactEmail" id="contactEmail" tabindex="6" /></td>
</tr>
<tr>
<td>Knox Account #<br />
<span class="details">(if you have one)</span></td>
<td><input type="text" name="knoxAccount" id="knoxAccount" tabindex="7" /></td>
</tr>
<tr>
<td> </td>
<td><input name="next" type="image" value="Next" src="../images/button-next.png" alt="Next" onmouseover="this.src='../images/button-next-over.png'" onmouseout="this.src='../images/button-next.png'" align="top" onclick="mysubmit();" /></td>
</tr>
</table>
</form>
</div>
...
and come up with nothing, it will not pop up that alert. Seems like it's not even running the function. Any ideas?
EDIT2: ok so I got it to run that above function and it popped up a box that said test before submitting so I did this...
Code: Select all
<script type='text/javascript'>
function mysubmit() {
var addy = document.getElementById("companyAddress").substr(0,1);
return addy;
alert('value of addy is' + addy);
}
</script>
and now it doens't run anymore. I am so freaking confused, why doesn't that run? Sorry I am kinda terrible with javascript.