calvinfoo
asked on
Client side VBScript: track numbers of input fields as in <input name="userID"/>
Hi,
I have multiple <input type="text" name="userID"> on client side, but I have no idea how many it will be before it submits (as user can dynamically click on "add"/"remove" any of the rows).
Question and problem
1. I need to do some clientside validation before submit back to server. Therefore I need to know how many userIDs were created. and the problem is when only ONE userID, it will be as text format; if MORE THAN ONE userID created, it will become an array format. Without knowing the numbers of userID, I cannot determine I should loop UserID as in array for validation or just get the UserID as in single text.
Please advice, thank you.
p/s: currently I put a hidden field as <input type="hidden" name="counter" value="1">
whenever user click on Add, it will +1, whenever user click on Delete, it will -1. I think this way is pretty stupid, and I hope this is not the way and the only way of doing it.
I have multiple <input type="text" name="userID"> on client side, but I have no idea how many it will be before it submits (as user can dynamically click on "add"/"remove" any of the rows).
Question and problem
1. I need to do some clientside validation before submit back to server. Therefore I need to know how many userIDs were created. and the problem is when only ONE userID, it will be as text format; if MORE THAN ONE userID created, it will become an array format. Without knowing the numbers of userID, I cannot determine I should loop UserID as in array for validation or just get the UserID as in single text.
Please advice, thank you.
p/s: currently I put a hidden field as <input type="hidden" name="counter" value="1">
whenever user click on Add, it will +1, whenever user click on Delete, it will -1. I think this way is pretty stupid, and I hope this is not the way and the only way of doing it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mensuck,
Since the title of the question is "Client side ..." and the question states "1. I need to do some clientside validation before submit back to server" it seems your suggestion doesn't really address the topic of this question.
Regards,
Rod
Since the title of the question is "Client side ..." and the question states "1. I need to do some clientside validation before submit back to server" it seems your suggestion doesn't really address the topic of this question.
Regards,
Rod
<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!