on validations

hi all,

     i have created an attribute in my table and declared it as varchar.now in my rules() i declared it as type=>string which is in "type" class.but if i enter number its taking ,so please help me

Well, a string is an array of characters. And a single digit is a character, so it’s perfectly normal that it validates numbers too… after all they are also strings :).

What you need is to use another type of validator: http://www.yiiframew…essionValidator

You can define a your regular expression like this for example:

/^[a-z]+$/

This will accept the following string:




a

aas

asdasd



But the following will fail as not valid




aAa

123a

a123

134



You can test you regular expression very easy here:

http://www.regular-e…iptexample.html

This site also offers tutorials about building regular expressions.