Stats: 3,249,646 members, 8,141,143 topics. Date: Tuesday, 22 April 2025 at 01:47 AM |
Nairaland Forum / Science/Technology / Programming / Python Challenge. (1061 Views)
The Greatest Programmer On Nairaland / . / Simple Code Challenge: C#, Java, C, C++ (2) (3) (4)
Python Challenge. by Otuabaroku: 1:50pm On Jul 14, 2013 |
Hi good people. I'm finding it difficult to understand why this code code is not working as expected. The code is meant to get the input from a form filled by the user. The text input which in this case is the subject validates but that of the textarea(content) is not validating. In other words, when the content is blank and the subject is filled the form submits. However, when the content is filled and the subject is blank, the form does not submit(which is the way it is suppose to be) The objective of the code is to ensure that both subject and content are filled by the user before submitting to database.
Thank you for your help. |
Re: Python Challenge. by lordZOUGA(m): 8:22pm On Jul 14, 2013 |
is this tornado framework? |
Re: Python Challenge. by Otuabaroku: 8:56pm On Jul 14, 2013 |
No. It is not tornado framework. I'm working on Google Appengine for python.I used Jinja library to escape html tags embedded in user input during submission(for validation purpose). |
Re: Python Challenge. by adewasco2k(m): 9:05pm On Jul 14, 2013 |
it looks okay with my little python knowledge, i have faced such problem before. 1. check correct spellings (case sensitivity) 2. for your <textarea></textarea> make sure no space in between your opening and closing tags or use a trim. okay, thats all i know ![]() 1 Like |
Re: Python Challenge. by Otuabaroku: 9:15pm On Jul 14, 2013 |
Thanks Ade. Exactly, that's why it was driving me crazy as I could not locate where the bug is.Just may be, I need to buy big googles lol. |
Re: Python Challenge. by kingscorps(m): 10:28pm On Jul 14, 2013 |
lol.Everyone makes mistakes in one way or the other. will look at the code for you and get back to you. |
Re: Python Challenge. by lordZOUGA(m): 10:12am On Jul 15, 2013 |
your problem is probably caused by the framework you are using |
Re: Python Challenge. by Picomon(m): 1:03pm On Jul 15, 2013 |
Are you talking about validation? |
Re: Python Challenge. by Picomon(m): 1:07pm On Jul 15, 2013 |
lordZOUGA: your problem is probably caused by the framework you are using Yeah, I guess you're right. The OP should look into validating of form in the framework documentation he's using. This stuff is easy to do in Django. |
Re: Python Challenge. by Picomon(m): 1:10pm On Jul 15, 2013 |
Well, @OP you can use javascript to validate user input. |
Re: Python Challenge. by Otuabaroku: 5:34am On Jul 16, 2013 |
Thank you guys. I finally found the cause of the bug. It was in my html file. Just realised that writing this line of code :<textarea rows="15" cols="80" name="content"> {{content}} </textarea> that way, instead of <textarea rows="15" cols="80" name="content">{{content}}</textarea> in a straight line was the cause of the bug. I'm using this exercise to learn web development in python and Google Appengine. It has been fun. This is the link to the final output:http://ebiblog3.appspot.com/blog |
Re: Python Challenge. by adewasco2k(m): 7:38am On Jul 16, 2013 |
Otuabaroku: Thank you guys. I finally found the cause of the bug. It was in my html file.you know i told you to be sure there is no space between your textarea tags...i have once faced the same problem...tabbing the closing textarea tag to the next line gives a space in between and if you dont trim it, if(content) will be true. ![]() |
Re: Python Challenge. by Otuabaroku: 7:43am On Jul 16, 2013 |
Yes. Ade, you are right. I never expected it was going to be the cause. You know, that big googles helped as well lol. |
Re: Python Challenge. by adewasco2k(m): 7:45am On Jul 16, 2013 |
I am loving python all over again...clean codes ![]() |
Re: Python Challenge. by Otuabaroku: 7:50am On Jul 16, 2013 |
Yes. Python is really tempting me. I'm original Java programmer. But was forced into python by one of my robotics course which was taught in python, since then, my interest in python has been increasing by day. |
(1) (Reply)
Java Programming Problem / Mediocrity As A Result Of Not Understanding Programming Concepts / Can I Create .php File Using "Fopen" Function.
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2025 Oluwaseun Osewa. All rights reserved. See How To Advertise. 22 |