[英]Next button will be disabled when user enter invalid date or month using jquery
[英]how to hide previous date and month in iOS using swift 3?
我正在使用幫助器libaray“WWCalendarTimeSelector”GitHub鏈接: - https://github.com/weilsonwonder/WWCalendarTimeSelector我有一個用戶注冊日期,它是29/9/2017。 現在我想只在下一個日期,月份和年份之間啟用日期。
當開始日期選擇和將來日期選擇其他日期禁用例如開始日期: - 29/09/2017和未來日期選擇02/10/2017看到之后的日期,您將被禁用...我該怎么做? 請幫忙....
@IBAction func btnSelectClick(_ sender: Any) {
let selector = UIStoryboard(name: "WWCalendarTimeSelector", bundle: nil).instantiateInitialViewController() as! WWCalendarTimeSelector
selector.delegate = self
selector.optionCurrentDate = singleDate
selector.optionCurrentDates = Set(multipleDates)
selector.optionCurrentDateRange.setStartDate(multipleDates.first ?? singleDate)
selector.optionCurrentDateRange.setEndDate(multipleDates.last ?? singleDate)
selector.optionStyles.showDateMonth(true)
selector.optionStyles.showMonth(false)
selector.optionStyles.showYear(true)
selector.optionStyles.showTime(false)
present(selector, animated: true, completion: nil)
}
func WWCalendarTimeSelectorDone(_ selector: WWCalendarTimeSelector, date: Date) {
print("Selected \n\(date)\n---")
singleDate = date
dateLabel.text = date.stringFromFormat("d' 'MMMM' 'yyyy', 'h':'mma")
}
func WWCalendarTimeSelectorDone(_ selector: WWCalendarTimeSelector, dates: [Date]) {
print("Selected Multiple Dates \n\(dates)\n---")
if let date = dates.first {
singleDate = date
dateLabel.text = date.stringFromFormat("d' 'MMMM' 'yyyy', 'h':'mma")
}
else {
dateLabel.text = "No Date Selected"
}
multipleDates = dates
}
您需要使用WWCalendarTimeSelectorShouldSelectDate
方法來禁用所需的日期/日期范圍。 以下示例可能對您有所幫助
fileprivate var today: Date = Date()
func WWCalendarTimeSelectorShouldSelectDate(_ selector: WWCalendarTimeSelector, date: Date) -> Bool{
let order = NSCalendar.current.compare(today, to: date, toGranularity: .day)
if order == .orderedDescending{ {
//Date selection will be disabled for past days
return false
} else {
//Allows to select from today
return true
}
}
您可以在上面的示例中使用自己的日期范圍
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.