Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextBox Validation

Status
Not open for further replies.

VbScriptor

Programmer
Apr 7, 2006
3
BE
i have a text box in my form in which the user enters his
name. As we all know a name cannot contain any no's. or any
thing else other than just alphabets right.

so if i insert a value other than just alphabets i should receive an error message right.

can this b done using vbscript (only vbscript & not javascript or asp).


i tried to use the isNumeric() but it works only if i insert all no's. in the text field
i.e it works only if i insert 65737 or any other no.
but not if i insert my747name

then i tried isAlpha() but it does not work at alll

is there any other way to do it in vbscript
(a sample code will be helpful)


thank you for your reply in advance
 
heres a sample code that checks for characters I don't want to be inputted.

you'll have to change it so it includes numbers.

call it by

clientsafeStr(Variable)


function clientsafeStr( inputValue )

clientmycnt=1
clientflag=0
do while clientmycnt<>len(inputValue)+1
if (mid(inputValue,clientmycnt,1)=&quot;'&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;^&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;\&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;/&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;(&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;)&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;#&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;~&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;<&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;>&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;|&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;`&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;¬&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;:&quot;)
or (mid(inputValue,clientmycnt,1)=&quot;;&quot;)
then

clientflag = 1
end if
clientmycnt=clientmycnt+1

loop

if clientflag=1 then
clientsafeStr = &quot;&quot;
alert(&quot;Illegal character entered - Please delete such characters from notes&quot;)

else
clientsafestr=inputValue
end if

end function


Mark
 
hey anyideas,

thank you very much for your reply,it seems that your code really works.
but there is a little problem which i dont know how to handle.

when i run ur code my internet explorer gives me an alert msg. saying
&quot;A script on this page is causing Internet Explorer to run slowly. If it continues to run your computer may become unresponsive.
Do you want to abort the script&quot;
I havent seen this kind of error message before.

if i ckick on yes button nothing happens, & if i click on no
IE stops responding.



is there any way out.

is there any other way to validate the text box in vbscript


please reply.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top