Check if textarea is empty, won't work |
[eluser]Fredrik-s[/eluser]
Hello, This is my third day using CodeIgniter and falling in love with it more and more. I have run into a problem though. I wan't to check so a textarea have anything written in it. If not I will output a message through a flash "function", if it has any thing written in it I will output a message saying everything is good also through a flash "function". My controller look like this: Code: function add_domains(){ My view looks like this: Code: <?PHP The thing is that it recognize when something is written and output the following "You HAVE wrote something, good!". But it doesn't recognize when there is NOT anything written. When I haven't written anything pressing the submit button the page just reload without any error message being displayed. How come the error message won't show up?
[eluser]oppenheimer[/eluser]
If I'm not mistaken, flash messages show up on the next page you load, not the current page. So the success message you are seeing was actually from loading the form. I think flash messages won't work well for this. You can just use a regular variable for your errors.
[eluser]InsiteFX[/eluser]
It's flashdata not just flash! Code: // To add flashdata: InsiteFX
[eluser]Fredrik-s[/eluser]
Thanks for replies! I'm using this library http://forrst.com/posts/Flashdata_with_e...gniter-0Dw which make me use the syntax presented in my code above. oppenheimer: I don't think the problem is that showing on the next page view. Because a new page view is generated and the one of the messages is coming through, which is "You HAVE wrote something, good!" Any other suggestions on what the problem could be?
[eluser]InsiteFX[/eluser]
Did you try to echo a message to make sure you are getting there? InsiteFX |
Welcome Guest, Not a member yet? Register Sign In |