two html onsumbit validation with java
I have these two java function for validation text input field and drop
down selection. I am trying to combine both validation onSubmit. it didn't
work when I put both validation together but it work when I put one at the
time.
function validname(fld) {
var error = "";
var valid = /^[a-zA-Z0-9\-]*$/;
if (fld.value == "") {
fld.style.borderColor = '#ff0000';
document.getElementById('name').style.color = "#ff0000";
error = " - Invalid device name..\n";
} else if(valid.test(fld.value)){
fld.style.borderColor = '';
document.getElementById('name').style.color = "#000000";
} else {
fld.style.borderColor = '#ff0000';
document.getElementById('name').style.color = "#ff0000";
error = " - Invalid device name. \n";
}
return error;
}
function ValidateDropForm() {
var isValidDropForm = true;
var errorMessages = "";
var e = document.getElementById('domain');
if (e.options[e.selectedIndex].text == "--Select--") {
document.getElementById('domainError').innerHTML = "- Domain name
required.";
isValidDropForm = false;
}
if (!isValidDropForm) {
//alert(errorMessages);
}
return isValidDropForm;
}
this what I did..
HTML <form action="" method="POST" onsubmit="return validateForm(this) &&
ValidateDropForm()">
No comments:
Post a Comment