Hi,
I have a form with certain fields to be filled in mandatorily.
If user doesn't fill mandates,onclick of submit button error message has to popup.
The error message has default text as : "Before submitting this form,make sure the following mandatory fields are completed:"
along with this the unfilled field names will be appended as error msg.
Following is the logic i tried..
But it doesnt seem to work....Can anyone please suggest me to improvise it?
function ExitForm(){
var msg = '';
var elem = document.form.elements;
var flag = 0;
//
condition to check if a field is filled. If no,
msg+= "\n"+"text1"
.
.
.
for textfields,textareas,radiobutton,dropdownlist
//
for(i=0;i<=elem.length;i++){
var ele = elem[i];
if(ele.type == "text" || ele.type == "radio" || ele.type == "textarea" || ele.type == "select"){
if ( ((ele.value == null) || (ele.value == "")) || isBlank(ele.value)){
flag = 1;
}
}
}
if (flag == 1)
{
alert("Before submitting this form,make sure the following mandatory fields are completed:"+msg);
}
}