function validate(form) {
while ($('#img').attr('src')=="../static/img/placeholder.png") {
return false;
}
return true;
}
^此代码对我不起作用。我想要一个在占位符 img 仍然存在时不提交的表单。我的代码犯了什么错误?
HTML:
<form method="post" action="/{{ curr_user }}" enctype="multipart/form-data" onSubmit="return validate(this);" >
<div class="submit-image">
<img id="img" src="../static/img/placeholder.png" onerror="this.src = '../static/img/placeholder.png'" alt="submitted image" />
</div>
<span class="input-url text">
<input type="text" id="url" placeholder="http://" maxlength="320"/>
</span>
<div class="form-actions">
<input type="submit" id="submit" name="op" value="Submit" class="form-submit"/
</div>
</form>