I have a form where I have to check form validation, grey out the submit button (so they don't press submit again and again) and then open a small window (in that order).

The form is for an upload of a file, so I know you can't use CFFORM and required=yes in text boxes for form validation (unless I'm mistaken, this would make things easier). And yes I do have enctype="multipart/form-data" in the form element as well.

So I want to know how (and where I put the other scripts) to complete this script and once all required fields are met, process the form by greying out the submit box and then open the progress window.

If there is a simpler way of doing this, I would appreciate it a lot..

On submit gets this script OnSubmit="return formCheck(this);"

ClientEmail and EditorEmail are a text boxes, Details is a TextArea and attachment is a file field.

function formCheck(formobj){
// Enter name of mandatory fields
var fieldRequired = Array("ClientEmail", "EditorEmail", "Details", "attachment");
// Enter field description to appear in the dialog box
var fieldDescription = Array("Your Email Address", "Editor Email", "Details", "Attachment");
// dialog message
var alertMsg = "Please complete the following fields:\n";

var l_Msg = alertMsg.length;

for (var i = 0; i < fieldRequired.length; i++){
var obj = formobj.elements[fieldRequired[i]];
if (obj){
switch(obj.type){
case "select-one":
if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "select-multiple":
if (obj.selectedIndex == -1){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "text":
case "file":
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
case "textarea":
if (obj.value == "" || obj.value == null){
alertMsg += " - " + fieldDescription[i] + "\n";
}
break;
default:
}
if (obj.type == undefined){
var blnchecked = false;
for (var j = 0; j < obj.length; j++){
if (obj[j].checked){
blnchecked = true;
}
}
if (!blnchecked){
alertMsg += " - " + fieldDescription[i] + "\n";
}
}
}
}


        if (alertMsg.length == l_Msg){
                return true;
        }else{
                alert(alertMsg);
                return false;
        }
}


Here is the script for greying out submit button

<script>
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
</script>

and on the Submit button itself onClick="winopen('progress.cfm','instwin',350,150)"


and here is the script
function winopen(url,winname,x,y){
var winleft = 150;
var wintop = 150;

var options = "toolbar=no,scrollbars=no,resizable=no,left=" + winleft + ",top=" + wintop + ",width=" + x + ",height=" + y;
msgWindow=window.open(url,winname,options);
}


Thanks

Carl

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to