仅在display = block(显示div)时验证要求并发送表格

时间:2019-05-16 07:50:40

标签: javascript forms validation hidden display

按下单选按钮“选项”时,将使用(display:none display:block)方法显示一个div。输入“ Requirements”是必需的,并且在html中有它。问题在于,当按下提交时,即使没有显示div,该表单也需要输入,因为用户尚未选择阻止CSS的单选按钮。仅当用户选择了单选按钮选项时,才应填写该字段。

谢谢!

val lockMap = ConcurrentHashMap<String, Semaphore>()

fun accessFile(fileName: String) {
    acquireSemaphore(fileName: String)
    acquireFileLock(fileName: String)
    doSomethingWithFile(fileName: String)
    releaseFileLock(fileName: String)
    releaseSemaphore(fileName: String)
}

fun acquireSemaphore(fileName: String) {
    (lockMap.computeIfAbsent(fileName){Semaphore(1, true)}).acquire()
}

fun releaseSemaphore(fileName: String) {
    lockMap[fileName]?.release()                // works, but the map keeps every semaphore
}

fun releaseSemaphore(fileName: String) {
    lockMap.remove(filename)?.release()     // removes the semaphore, but causes OverlappingFileLockExceptions
}

0 个答案:

没有答案