I have a single form field that asks for "Full Name" when the user signs up. I want to then split that string into first name and then surname. I can get that working with the following code:
<%
If Request.Form("user[username]") <> "" Then
NameStr = Request.Form("user[username]")
Dim WordArray
WordArray = Split(NameStr, " ")
End If
%>
From that I can then split the variables into my form with:
value="<%=WordArray(0)%>"
value="<%=WordArray(1)%>"
However, if the user just puts their first name in I get an error as the Split is looking for a space between the words to perform the action correctly. I have tried:
<%
If Request.Form("user[username]") <> "" Then
NameStr = Request.Form("user[username]")
Dim WordArray
If NameStr = "" Then
WordArray = Split(NameStr, "")
Else
WordArray = Split(NameStr, " ")
End If
End If
%>
Now I knew this would fail as it will never be blank but is there a way to look to see if the Split will error if there is only a first name and no surname? I have looked at validating the form field but cannot see a way of ensuring it has a space between them.
Any ideas?