I have a form with which I am using Smarty Streets Live Address validation. In general it works well. In the case where a user has begun entering address information, though, the Live Address validation can get in the way. The most specific problem encountered is in the case where address information has been entered but the user chooses to cancel the form. The Live Address validation takes precedence of operation and blocks attempts to deactivate the validation and clear the form.
A fiddle example of the issue can be found here.
<form>
<input type="text" id="street" name="street" placeholder="street"><br>
<input type="text" id="city" name="city" placeholder="city"><br>
<input type="text" id="state" name="state" placeholder="city"><br>
<input type="text" id="ZIP" name="ZIP" placeholder="ZIP"><br>
<button id="btnCancel">Cancel</button>
</form>
<script>
var ss = jQuery.LiveAddress({ key: '5640108848289556771', debug: true })
$(function () {
$("#btnCancel").click(function (e) {
e.preventDefault();
alert("click");
ss.deactivate();
});
});
</script>
When no data has been entered the click event works as desired, but once address information has been entered the Live Address validation prevents the event handler from firing.
On the click of the cancel button the form should be cleared or returned to the previous page, but instead the Live Address validation takes over and blocks all other actions.
How can the Live Address validation be deactivated on the button click event?