|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
check if the given input has the expected type
how do i enforce constraints on input types
for example correct input i.e if i need to enter text not numbers i should be given an error message when text is entered. how do i guard against empty fields. i also have a problem with entering data with space inbetween. for example if i have the field name and i enter "john doe" when i refer to the variable $name in an sql query it doesn't work because only "john" is seen. how can i solve this. |
|
#2
|
|||
|
|||
|
Sounds like you need some regular expressions. Do a search for regex, grep and ereg. There is a lot of information out there about text parsing. I believe there is even a site that has "recipes" for regular expressions, but I can't remember where it is right now.
As far as checking for empty fields, that depends on your programming language. Most have a construct like (isempty($x)) or (length($x) = 0) that you can use. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > check if the given input has the expected type |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|