Reputation: 2576
I'm starting simple CURD operation with python Flask framework and i want to when user submit form how to check users selected value null or not?
I was tried this
if request.method == 'POST':
Name = request.form.get('Name')
city = request.form.get('City')
if Name == '' and city == '':
print('its null')
else:
print('success')
but when i'm submit without fill any value its give output
success
i'm also try None and null but can't work.
Upvotes: 2
Views: 14594
Reputation:
i tried your above method..it is working for me."remember" is checkbox input type in my html.
@app.route('/login',methods=['POST'])
def login_validate():
email=request.form['email']
password=request.form['pass']
remember=request.form.get('remember')
if remember:
print "present"
else:
print "not present"
Upvotes: 3