I am creating a comments board and via Javascript i am attempting to implement a piece of script which will prevent the user from submitting a paragraph if it has a undesirable word(s) in it. I have looked online and struggled to find any examples. This is what i have so far but not sure if i should be using index.of
index.php
<div class="askComment">
    <h2>Submit new comment</h2>
    <!--comment form -->
    <form id="form" method="post">
        <!-- need to supply post id with hidden fild -->
        <input type="hidden" name="postid" value="<?php echo $post; ?>">
        <input type="hidden" name="type" value="A">
            <p>Hello <strong><?php echo $fname; ?></strong> what do you have to say</p>
            <input type="hidden" name="fname" id="comment-name" value="<?php echo $fname; ?>" >
            <input type="hidden" name="userid" id="comment-mail" value="<?php echo $UserId; ?>" >
            <p>Your comment *</p>
            <textarea name="comment" id="comment" cols="30" rows="10" placeholder="Type your comment here...." ></textarea>
            <div id="error"></div>
        <input type="submit" id="submit-comment" name="submit" value="Submit Comment">
    </form>
    </div>
mod_comment.php
$(document).ready(function () {
    document.getElementById("submit-comment").disabled = true;
    var swear = new Array();
    swear[0] = "jelly";
    swear[1] = "trumpet";
    swear[2] = "chocolate";
    $("#comment").change(function () {
        var comment = $("#comment").val();
        if (comment.indexOf('????') === -1) {
            $("#error").html('<font color="red">Please rewrite <strong>bad</strong> word found.</font>');
        } else {
            document.getElementById("loginsubmit").disabled = false;
        }
    });
});
 
     
     
     
    