how would i go about parsing the value and checking if it contains spaces
or a special character? i tried converting a javascript into a server
validation function, it says that the 'indexof' and 'substring' from
javascript are not members
of 'System.Web.UI.WebControls.ServerValidateEventArgs'...
<code>
<%@ Page Language="VB" %>
<script runat="server">
dim ch as string
Sub Page_Load(sender As Object, e As EventArgs)
lbloutput1.text = "Please fill in ALL the required fields"
lbloutput2.text = "Password may be no more than 10 characters in
length."
lbloutput3.text = "Blank spaces are not allowed the password"
lbloutput4.text = "'" & ch & "' not allowed in Password. Please
enter only lower case letters, numbers, ' . ' or ' _ '"
End Sub
Public Sub required_chk(sender as object, value as ServerValidateEventArgs)
If not(value.indexof(" ") = -1) then
lbloutput3.visible = true
value.IsValid = false
exit sub
End if
dim i = 0
for i = 1 to val(Len(value))
dim alphanumspecial
= "abcdefghijklmnopqrstuvwxyz0123456789_."
dim ch = value.substring(i, i+1)
if (alphanumspecial.indexof(ch) = -1) then
lbloutput4.visible = true
value.IsValid = false
exit sub
End if
next i
end sub
</script>
<html>
<body>
<form id="postNew" runat="server">
<asp:label id="lbloutput1" runat="server" />
<asp:label id="lbloutput2" runat="server" />
<asp:label id="lbloutput3" runat="server" />
<asp:label id="lbloutput4" runat="server" />
<asp:CustomValidator id="pass1" runat="server"
onservervalidate="required_chk" ControlToValidate="pass" />
</form>
</body>
</html>
</code>
the original javascript...
<code>
<form method=POST action=/s/resetpassword?r=second name=form1
onsubmit="return submitRequest()">
function submitRequest() {
var str= document.forms.form1.elements["MemberID"].value;
if (str.length > 8) {
document.forms.form1.elements["MemberID"].focus();
alert("Member ID may be no more than 8 characters in length.");
return false;
}
if(str.indexOf(' ')!=-1) {
document.forms.form1.elements["MemberID"].focus();
alert( 'Blank(s) are not allowed in Member ID. ');
return false;
}
var alphanumspecial = 'abcdefghijklmnopqrstuvwxyz0123456789_.';
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i+1);
if (alphanumspecial.indexOf(ch) == -1) {
document.forms.form1.elements["MemberID"].focus();
alert( "'" +ch+"' " + "not allowed in Member ID. Please enter only
lower case letters, numbers, ' . ' or ' _ '");
return false;
}
}
}
</script></code>
thanx ahead of time for any advice...