I'd like to activate the validation alert when I click on the following. How can I do this?Please let me know if you know more.Thank you for your cooperation.
<a href="#"onclick=" document.insert.submit()"id="senddiv">Save</a>
<form id="form" method="post" name="insert" action="enctype="multipart/form-data">
<input type="text" name="tags" id="tags">
</form>
<script>
$(function(){
$('#form').submit(function(){
if($('[name="tags"]US>').val()=='){
alert("Please enter a tag.");
return false;
}
return true;
});
});
</script>
I think it would be better to set the onclick attribute value of tag as below.
<a href="#"onclick="$('#form').submit()"id="senddiv">Save</a>
You should now be able to call the event handler that you are working on in JavaScript.
If you don't mind using Safari,
<form method="post" action="enctype="multipart/form-data">
<input type=submit value="Save"><br>
<label>tags:<input name="tags" required></label>
</form>
I think this alone will almost accomplish my purpose.JavaScript is not required.
© 2024 OneMinuteCode. All rights reserved.