coutts
08-06-2008, 05:28 PM
Hello:
I was wondering what I have done wrong below. The form always validates and proceeds to insert.php. I have even put alert('Hello'); at the begining of teh javascript and I dont ever see that either so I am assuming that the javascript function isnt even being called. I have tried adding onClic to the submit button as well - same results HELP PLEASE
Thanks
Robert
<script language="javascript" type="text/javascript">
function checkForm(){
var pub_percent1=Number(document.addform.pub_percent1.value);
var pub_percent2=Number(document.addform.pub_percent2.value);
var pub_percent3=Number(document.addform.pub_percent3.value);
var pub_percent4=Number(document.addform.pub_percent4.value);
var song_percent1=Number(document.addform.song_percent1.value);
var song_percent2=Number(document.addform.song_percent2.value);
var song_percent3=Number(document.addform.song_percent3.value);
var song_percent4=Number(document.addform.song_percent4.value);
var song_total=song_percent1+song_percent2+song_percent3+song_percent4;
var pub_total=pub_percent1+pub_percent2+pub_percent3+pub_percent4;
if(pub_total != 100) || (song_total != 100)
{
alert('Your Royalties do not add up to 100% - Please try again');
return false;
}
}
</script>
<form action="insert.php" method="post" name="addform" onsubmit="return checkForm();">
I was wondering what I have done wrong below. The form always validates and proceeds to insert.php. I have even put alert('Hello'); at the begining of teh javascript and I dont ever see that either so I am assuming that the javascript function isnt even being called. I have tried adding onClic to the submit button as well - same results HELP PLEASE
Thanks
Robert
<script language="javascript" type="text/javascript">
function checkForm(){
var pub_percent1=Number(document.addform.pub_percent1.value);
var pub_percent2=Number(document.addform.pub_percent2.value);
var pub_percent3=Number(document.addform.pub_percent3.value);
var pub_percent4=Number(document.addform.pub_percent4.value);
var song_percent1=Number(document.addform.song_percent1.value);
var song_percent2=Number(document.addform.song_percent2.value);
var song_percent3=Number(document.addform.song_percent3.value);
var song_percent4=Number(document.addform.song_percent4.value);
var song_total=song_percent1+song_percent2+song_percent3+song_percent4;
var pub_total=pub_percent1+pub_percent2+pub_percent3+pub_percent4;
if(pub_total != 100) || (song_total != 100)
{
alert('Your Royalties do not add up to 100% - Please try again');
return false;
}
}
</script>
<form action="insert.php" method="post" name="addform" onsubmit="return checkForm();">