Just use 'for each' in your server side VBScript, it will handle both single element inputs or array element type inputs if the 'form' element is a array!
<script language="VBScript" runat="Server">
dim opt
if ( request.form ( "userID" ) <> "" ) then
for each opt in request.form ( "userID" )
' validation function call or validation goes here, example just shows the form data
response.write ( opt & "<br />" )
next
end if
</script>
ms!
Main Topics
Browse All Topics





by: rdivilbissPosted on 2005-08-18 at 20:35:01ID: 14706296
Client side VBScript will only work on IE.
gName('INP UT'); ') {
Using JavaScript you can validate all the fields without knowing in advance how many there are.
<form name="frm" method="post" action="somepage.asp" onsubmit="return validate(this);">
<script type="text/javascript">
function validate(frm) {
var inputs=frm.getElementsByTa
for (var idx=0; idx<inputs.length; idx++) {
if (inputs[idx].name=='userID
// validation here, I'll check for empty
if (inputs[idx].value=='') {
alert('UserID can not be empty');
inputs[idx].focus();
return false;
}
}
}
return true;
}
That function will get all the inputs and validate the ones named userID. You can put whatever validation you need in the function and it does not matter how many fields you have or that they all have the same name.
Also it cross browser, as opposed to VBScript on the client side.
Regards,
Rod