删除上传的图像后,jQuery验证无法正常工作

时间:2016-10-25 08:00:40

标签: jquery

在下面的小提琴

http://jsfiddle.net/Luf0ks9b/22/

步骤1.选择任意图像并上传

步骤2.单击“删除”按钮

现在点击“提交”按钮,输入类型文件的验证失败了吗?

它不要求输入文件

这是我的代码

from io import StringIO
import pandas as pd
import numpy as np

string = "a,b\n0,'x'\n1,'y'\n2,'z'\n'END','END'"

# Test that it works
pd.read_csv(StringIO(string))
#       a      b
#0      0    'x'
#1      1    'y'
#2      2    'z'
#3  'END'  'END'

# Now with data types and iteration

# ValueError: invalid literal for int() with base 10: "'END'"
data = pd.read_csv(StringIO(string), dtype={'a': np.int, 'b': np.str}, chunksize=2)
for df in data: 
    print(df)

# Same error message with error_bad_lines=False
data = pd.read_csv(StringIO(string), dtype={'a': np.int, 'b': np.str}, chunksize=2, error_bad_lines=False)
for df in data: 
    print(df)

# Trying to skip the footer: 
# ValueError: skip_footer not supported for iteration
data = pd.read_csv(StringIO(string), converters={'a': np.int, 'b': np.str}, chunksize=2, skipfooter=1, engine='python')
for df in data: 
    print(df)

# In this mwe, comment='E' gives a different error than in my real data, but still
# ValueError: invalid literal for int() with base 10: "'"
data = pd.read_csv(StringIO(string), dtype={'a': np.int, 'b': np.str}, chunksize=2, comment='E')
for df in data:
    print(df)

1 个答案:

答案 0 :(得分:1)

我已经更新了你的fiddle,它正在删除用于验证的输入的名称属性,我只是在按下删除按钮时将其恢复,因此验证现在正常工作。< / p>

$(document).on("click", ".removepic", function(event) {

    $("#previewpic").attr('name', 'previewpic');

});