function validate(form) {
while ($('#img').attr('src')=="../static/img/placeholder.png") {
return false;
}
return true;
}
^This code does not work for me. I want to have a form that does not submit while the placeholder img still exists. What mistake am I making with my code?
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>
From your current example, this should be enough:
See a more detailed example here: http://jsfiddle.net/ENnLC/