lundi 19 octobre 2020

Function does not execute on razor page when called from javascript file

I have been trying to call my function in the 'onsubmit' part of my form however, whenever I execute my application the alert is not appearing when searching an empty string.

When the function is written in the razor page itself (using script tags), it works fine. It seems like if I separate this function in its own javascript file, it does not want to work.

Razor Page Code:

MainHomePage Razor Page

My Javascript file:

function CheckForBlank() {
if (!document.getElementById("searchInput").value.trim().length) {
    alert("Please enter a card name.");
    return false;
}}

Any help on this would be very much appreciated.

Aucun commentaire:

Enregistrer un commentaire