0

I've used this same code with the data being different from another website and it worked locally and online but this new website wont accept the form gives me an error, anyone can help?

HTML- Script:

   <script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript"></script>
<meta charset="utf-8">
<title>Untitled Document</title>

<script>
$(function() {
    $("#Message").validate({
        rules: {
            Name: {
                required: true,
                minlength: 2,
                maxlength: 15
                },
            Email: {
                required: true,
                email: true
                },
            Message: {
                required: true,
                minlength: 10
                 }
    }});

});
                </script>

Form:

<p><form id="Message" method="POST" action="message.php">
<p>Enter Name: <input id="Name" type="text" name="Name" size="20"></p>
<p>Enter Email: <input id="Email" type="text" name="Email" size="20"></p>
<p>Message: <input id="Message" type="text" name="Message" size"20"></p>
<p><input type="submit" value="Submit" name="Submit"></p> 

PHP Message.php:

<?php

## CONFIG ##

# LIST EMAIL ADDRESS
$recipient = "MYEMAIL";

# SUBJECT (Subscribe/Remove)
$subject = "WebMsg";

# RESULT PAGE
$location = "received.html";

## FORM VALUES ##

$sender = $recipient;

# MAIL BODY
$body .= "Name: ".$_REQUEST['Name']." \n";
$body .= "Email: ".$_REQUEST['Email']." \n";
$body .= "Message: ".$REQUEST['Message']." \n";
# add more fields here if required

## SEND MESSGAE ##

mail( $recipient, $subject, $body, "From: $sender" ) or header( "Location: $location" );

## SHOW RESULT PAGE ##

header( "Location: $location" );
?>

and finally the console error:

Uncaught TypeError: $(...).validate is not a function(anonymous function) @ index.html:15v.Callbacks.l @ jquery-1.8.3.min.js:2v.Callbacks.c.fireWith @ jquery-1.8.3.min.js:2v.extend.ready @ jquery-1.8.3.min.js:2A @ jquery-1.8.3.min.js:2

I'd be very grateful if someone could reply and help me this is anoying me now

Sparky
  • 98,165
  • 25
  • 199
  • 285

1 Answers1

1

validate is not a Jquery function. You need to include this to use the validate method: https://github.com/jzaefferer/jquery-validation

Just include it after Jquery:

<script src="http://code.jquery.com/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="jquery.validate.js"></script>
michelem
  • 14,430
  • 5
  • 50
  • 66