<script language="javascript" type="text/javascript">
function validate() {
// Get all input controls
var arrTextBox = document.getElementsByTagName("input");
var retValue = 1;
// Loop through all controls
for(i=0;i<arrTextBox.length;i++)
{
// Check whether control is textbox and has a value
if (arrTextBox[i].type == "text" && arrTextBox[i].value == "") {
retValue = 0;
}
}
//based on the validation return the value
if (retValue == 0) {
alert("Validation Failed");
return false;
}
else {
alert("Validation Success");
return true;
}
}
<script>
Tags : Validate JavaScript, All TextBoxes, document.getElementByTagName
No comments:
Post a Comment