Preventing Form Submission based on connected object field value

I am trying to prevent a charge based on the specified value in a connected object, using the example code provided by Knack below, which I have amended.

While I have experience with HTML5 and CSS, I have almost no experience with writing Javascript. Can anyone please advise me where I am going wrong, or whether I am even heading in the right direction with the code below. This code seems to prevents all charges from being submitted, despite specific value not shown as "booked".

Long story short, I am trying to prevent a second charge from being submitted when the connected object has already been "booked" by another customer. Unfortunately, Knack's inbuilt validation features don't allow what I am looking for.

I've tried the Knack Builder Network, but it apparently seems like costly business having custom code written for my solution.

Any help would be very much appreciated.

// Your app's ViewID and FieldID will need updated.
$(document).on('knack-view-render.view_9', function(event, view, data) {

$("#view_9 .kn-submit input[type=submit]").on("click", function() {
// if this value in my form doesn't equal "SpecificValue" then prevent the form from submitting
if ($("#object_1-field_4").val() != "Booked") {
alert ("Sorry, this journey has been booked by another customer and is no longer available.");
return false;


Try Below Code, it worked for me:

return false;

Maybe I'm not understanding, but if you want to prevent the submission when field_4 is "Booked", shouldn't it be....

if ($("#object_1-field_4").val() == "Booked") {