简体   繁体   中英

How to prompt user to input the time in a specific format?

I was wondering if there's a way to ask the user to input the time in a single input bar following the specific format for datetime, so the user will have no choice but to use the specified format.

Like this:

在此处输入图片说明

here is a plugin for jquery if your project has one

$("#date").mask("9999-99-99 99:99:99");

You can use dateutil for checking date serverside

from dateutil.parser import parse

def is_date(string):
    try:
        parse(string)
        return True
    except ValueError:
        return False

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM