Hello,
I have one question about including a
JS file on my ASP page. Asp works fine. When I include a
JS file, it does not do anything when I hit "Submit". It should check for empty fields.
Does it relate to onChange="javascript
:frmSelect.submit(); on my ASP page?
If yes, how do I fix it to make my form validation work?
Thanks so much.
Here is my code:
<head>
<title>Example combo box</title>
<script language="JavaScript" type="text/javascript" src="inc/
js.
js"></script>
</head>
<form name="frmSelect" method="Post" action="selectcombo1.asp">
...
<SELECT name="cars" onChange="javascript
:frmSelect.submit();">
...
<p><input name="Submit" type="submit" value="Submit"></p>
----------------------------------------------------------
js.
js file:
var maxC=100;
function limC(obj){
while(obj.value.length>maxC){
obj.value=obj.value.replace(/.$/,'');
}
}
function chFrm() {
var digits = "0123456789"; // Email validation check
var chEmail = new RegExp("^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$") // Email validation check
var errs = 0
var msgbox = "You forgot the following question (s).\nPlease complete and re-submit. Thanks!\n";
var goon = msgbox
var ctr = 0;
var radioCk = false;
for (i = 0; i < document.frmSelect.Q1.length; i++) {
if (document.frmSelect.Q1[i].checked)
radioCk = true; }
if (!radioCk) {
msgbox = msgbox + "\n Question #1 - Please check one box";
}
if (document.frmSelect.Q3.value=="") {
msgbox = msgbox + "\n Question #3 - Please add your comments";
}
// If no errors found, then go ahead to submit the form
if (msgbox == goon) {
return true;
} else {
alert(msgbox);
return false;
}
}
---------------------
There is NO stupid question.