Min length for text area in my form2019 Community Moderator ElectionLength of a JavaScript objectJavaScript post request like a form submitjQuery get specific option tag textjQuery Set Cursor Position in Text AreaConvert form data to JavaScript object with jQueryGet selected text from a drop-down list (select box) using jQueryjQuery AJAX submit formJquery Super box automatically loadsJQuery code not runsEditing a text area with a form

What is the blue range indicating on this manifold pressure gauge?

Am I not good enough for you?

If the Captain's screens are out, does he switch seats with the co-pilot?

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

The meaning of the "at the of"

validation vs test vs training accuracy, which one to compare for claiming overfit?

What is the dot in “1.2.4."

What to do when during a meeting client people start to fight (even physically) with each others?

Potentiometer like component

"However" used in a conditional clause?

How do anti-virus programs start at Windows boot?

How is the Swiss post e-voting system supposed to work, and how was it wrong?

Do items de-spawn in Diablo?

Is it ok to include an epilogue dedicated to colleagues who passed away in the end of the manuscript?

Why do Australian milk farmers need to protest supermarkets' milk price?

What is the definition of "Natural Selection"?

Single word request: Harming the benefactor

Time dilation for a moving electronic clock

How could a female member of a species produce eggs unto death?

Best mythical creature to use as livestock?

Touchscreen-controlled dentist office snowman collector game

Counter-example to the existence of left Bousfield localization of combinatorial model category

Unreachable code, but reachable with exception

My story is written in English, but is set in my home country. What language should I use for the dialogue?



Min length for text area in my form



2019 Community Moderator ElectionLength of a JavaScript objectJavaScript post request like a form submitjQuery get specific option tag textjQuery Set Cursor Position in Text AreaConvert form data to JavaScript object with jQueryGet selected text from a drop-down list (select box) using jQueryjQuery AJAX submit formJquery Super box automatically loadsJQuery code not runsEditing a text area with a form










0















I need to set a min length and a max length for my text area box on my website. I know for max i can do it in html, but min you cannot. Could someone help me with this? I can do if, else statements but that would be after the form is submitted. I want it to tell the user the length is too short before he/she even submits it. I think jquery would be the best but really unsure.



Code listed below.



 <!DOCTYPE HTML>
<html>
<head>

<link type="text/css" rel="stylesheet" href="index.css" />
<meta name="viewport" content="width=device-width" />
<title>Daily Dorm News</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function()
$( "#datepicker" ).datepicker();
$('form').submit(function (e)
var value;

// "message" pattern : from 3 to 15 alphanumerical chars

value = $('[name="message"]').val();
if (!/^[A-Za-z0-9]2,150$/.test(value))
alert('Need to enter at least 3 characters to submit this form.');
e.preventDefault();



);
);
</script>

</head>
<body>
<h1> <u>Daily Dorm News</u> <br> The best place to get your latest Dorm news </h1>
<form action="posting_wall.php" method="get">
<div id="container">
Username:<input type="text" name="name" pattern="[A-Za-z0-9]3,15" title="Letters and numbers only, length 3 to 15" required autofocus><br>
E-mail: <input type="email" name="email" maxlength="20" required><br>

Post:<br>
<div name="message">
<textarea rows="15" cols="50" name='message' required></textarea>
</div>
Date this event took place: <input type="text" name='date' id="datepicker" required> <br>
<input type="reset" value="Reset">
<input type="submit">

</form>

</body>
</html>









share|improve this question




























    0















    I need to set a min length and a max length for my text area box on my website. I know for max i can do it in html, but min you cannot. Could someone help me with this? I can do if, else statements but that would be after the form is submitted. I want it to tell the user the length is too short before he/she even submits it. I think jquery would be the best but really unsure.



    Code listed below.



     <!DOCTYPE HTML>
    <html>
    <head>

    <link type="text/css" rel="stylesheet" href="index.css" />
    <meta name="viewport" content="width=device-width" />
    <title>Daily Dorm News</title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" />
    <script>
    $(function()
    $( "#datepicker" ).datepicker();
    $('form').submit(function (e)
    var value;

    // "message" pattern : from 3 to 15 alphanumerical chars

    value = $('[name="message"]').val();
    if (!/^[A-Za-z0-9]2,150$/.test(value))
    alert('Need to enter at least 3 characters to submit this form.');
    e.preventDefault();



    );
    );
    </script>

    </head>
    <body>
    <h1> <u>Daily Dorm News</u> <br> The best place to get your latest Dorm news </h1>
    <form action="posting_wall.php" method="get">
    <div id="container">
    Username:<input type="text" name="name" pattern="[A-Za-z0-9]3,15" title="Letters and numbers only, length 3 to 15" required autofocus><br>
    E-mail: <input type="email" name="email" maxlength="20" required><br>

    Post:<br>
    <div name="message">
    <textarea rows="15" cols="50" name='message' required></textarea>
    </div>
    Date this event took place: <input type="text" name='date' id="datepicker" required> <br>
    <input type="reset" value="Reset">
    <input type="submit">

    </form>

    </body>
    </html>









    share|improve this question


























      0












      0








      0








      I need to set a min length and a max length for my text area box on my website. I know for max i can do it in html, but min you cannot. Could someone help me with this? I can do if, else statements but that would be after the form is submitted. I want it to tell the user the length is too short before he/she even submits it. I think jquery would be the best but really unsure.



      Code listed below.



       <!DOCTYPE HTML>
      <html>
      <head>

      <link type="text/css" rel="stylesheet" href="index.css" />
      <meta name="viewport" content="width=device-width" />
      <title>Daily Dorm News</title>
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
      <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
      <link rel="stylesheet" href="/resources/demos/style.css" />
      <script>
      $(function()
      $( "#datepicker" ).datepicker();
      $('form').submit(function (e)
      var value;

      // "message" pattern : from 3 to 15 alphanumerical chars

      value = $('[name="message"]').val();
      if (!/^[A-Za-z0-9]2,150$/.test(value))
      alert('Need to enter at least 3 characters to submit this form.');
      e.preventDefault();



      );
      );
      </script>

      </head>
      <body>
      <h1> <u>Daily Dorm News</u> <br> The best place to get your latest Dorm news </h1>
      <form action="posting_wall.php" method="get">
      <div id="container">
      Username:<input type="text" name="name" pattern="[A-Za-z0-9]3,15" title="Letters and numbers only, length 3 to 15" required autofocus><br>
      E-mail: <input type="email" name="email" maxlength="20" required><br>

      Post:<br>
      <div name="message">
      <textarea rows="15" cols="50" name='message' required></textarea>
      </div>
      Date this event took place: <input type="text" name='date' id="datepicker" required> <br>
      <input type="reset" value="Reset">
      <input type="submit">

      </form>

      </body>
      </html>









      share|improve this question
















      I need to set a min length and a max length for my text area box on my website. I know for max i can do it in html, but min you cannot. Could someone help me with this? I can do if, else statements but that would be after the form is submitted. I want it to tell the user the length is too short before he/she even submits it. I think jquery would be the best but really unsure.



      Code listed below.



       <!DOCTYPE HTML>
      <html>
      <head>

      <link type="text/css" rel="stylesheet" href="index.css" />
      <meta name="viewport" content="width=device-width" />
      <title>Daily Dorm News</title>
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
      <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
      <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
      <link rel="stylesheet" href="/resources/demos/style.css" />
      <script>
      $(function()
      $( "#datepicker" ).datepicker();
      $('form').submit(function (e)
      var value;

      // "message" pattern : from 3 to 15 alphanumerical chars

      value = $('[name="message"]').val();
      if (!/^[A-Za-z0-9]2,150$/.test(value))
      alert('Need to enter at least 3 characters to submit this form.');
      e.preventDefault();



      );
      );
      </script>

      </head>
      <body>
      <h1> <u>Daily Dorm News</u> <br> The best place to get your latest Dorm news </h1>
      <form action="posting_wall.php" method="get">
      <div id="container">
      Username:<input type="text" name="name" pattern="[A-Za-z0-9]3,15" title="Letters and numbers only, length 3 to 15" required autofocus><br>
      E-mail: <input type="email" name="email" maxlength="20" required><br>

      Post:<br>
      <div name="message">
      <textarea rows="15" cols="50" name='message' required></textarea>
      </div>
      Date this event took place: <input type="text" name='date' id="datepicker" required> <br>
      <input type="reset" value="Reset">
      <input type="submit">

      </form>

      </body>
      </html>






      javascript php jquery






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 3 '13 at 20:09







      Terry

















      asked Nov 2 '13 at 18:29









      TerryTerry

      72212




      72212






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Set min-length



          pattern=".5," --> 5 characters minimum


          set both min-length and max-length



          pattern=".5,100" --> 5 characters minimum and 100 maximum .


          Example



          <input type="text" name="test" pattern=".20,100" required >


          to support Html5 in every browser use html5shiv




          Updated after OP's comment

          $('#myform').submit(function(e)
          if($('#message').val().length < 3)
          e.preventdefault();

          );





          share|improve this answer




















          • 1





            like so? "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> "

            – Terry
            Nov 2 '13 at 18:36











          • @Terry yeah ..!!

            – Tushar Gupta
            Nov 2 '13 at 18:37











          • hmm i tried, still let me submit eventhough I had only 1 character in the message field

            – Terry
            Nov 2 '13 at 18:37












          • use an hml5 validation polyfill to make sure it works in all browsers.

            – dandavis
            Nov 2 '13 at 18:51











          • it does not validate, and does not work. I had it as "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> " but it still let me submit only 1 character. any idea how? I just want it so if you enter less then 3 characters it wont let you post

            – Terry
            Nov 2 '13 at 18:53


















          0














          Note that your HTML misses </head>. That said, the "pattern" attribute seems to work :



          <input type="text" required="required" pattern="^[A-Za-z0-9]3,15$" />


          Here is another way of doing this using Javascript. Just put this code into the <head> section, right after $("#datepicker").datepicker(); :



          $('form').submit(function (e) 
          var nameValue = $('[name="name"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(nameValue))
          alert('failure');
          e.preventDefault(); // prevents from submitting

          );


          Here is a demo combining both solutions : http://jsfiddle.net/wared/KbxM8/.



          See also : http://api.jquery.com/submit/




          I've tried something according to your comments :



          $('form').submit(function (e) 
          var value;

          // "message" pattern : from 3 to 15 alphanumerical chars

          value = $('[name="message"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(value.replace(/n/g, '')))
          alert('Wrong value for "message".');
          e.preventDefault();
          return;


          // "name" pattern : at least 1 digit

          value = $('[name="name"]').val();
          if (!/d+/.test(value))
          alert('Wrong value for "name".');
          e.preventDefault();
          return;

          );





          share|improve this answer

























          • Worked great thank you! Now can I use some form of this to MAKE the user submit atleast 1 numeral in the username field?

            – Terry
            Nov 2 '13 at 20:29











          • hold on, I had it working, but now its not. I put [name="name"] as [name="message"] since the name of the text area is message.

            – Terry
            Nov 2 '13 at 21:50












          • hmm? I dont get what you mean

            – Terry
            Nov 2 '13 at 23:46











          • I updated the code in the OP to show what I have, must just be a small error,

            – Terry
            Nov 2 '13 at 23:51











          • Nope, still does not have an effect. I tried putting it in the header, and in the form, neither worked. I'll paste the updated code above, just so you can see what I am doing. Hmm, so weird

            – Terry
            Nov 3 '13 at 18:06










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19745339%2fmin-length-for-text-area-in-my-form%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Set min-length



          pattern=".5," --> 5 characters minimum


          set both min-length and max-length



          pattern=".5,100" --> 5 characters minimum and 100 maximum .


          Example



          <input type="text" name="test" pattern=".20,100" required >


          to support Html5 in every browser use html5shiv




          Updated after OP's comment

          $('#myform').submit(function(e)
          if($('#message').val().length < 3)
          e.preventdefault();

          );





          share|improve this answer




















          • 1





            like so? "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> "

            – Terry
            Nov 2 '13 at 18:36











          • @Terry yeah ..!!

            – Tushar Gupta
            Nov 2 '13 at 18:37











          • hmm i tried, still let me submit eventhough I had only 1 character in the message field

            – Terry
            Nov 2 '13 at 18:37












          • use an hml5 validation polyfill to make sure it works in all browsers.

            – dandavis
            Nov 2 '13 at 18:51











          • it does not validate, and does not work. I had it as "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> " but it still let me submit only 1 character. any idea how? I just want it so if you enter less then 3 characters it wont let you post

            – Terry
            Nov 2 '13 at 18:53















          0














          Set min-length



          pattern=".5," --> 5 characters minimum


          set both min-length and max-length



          pattern=".5,100" --> 5 characters minimum and 100 maximum .


          Example



          <input type="text" name="test" pattern=".20,100" required >


          to support Html5 in every browser use html5shiv




          Updated after OP's comment

          $('#myform').submit(function(e)
          if($('#message').val().length < 3)
          e.preventdefault();

          );





          share|improve this answer




















          • 1





            like so? "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> "

            – Terry
            Nov 2 '13 at 18:36











          • @Terry yeah ..!!

            – Tushar Gupta
            Nov 2 '13 at 18:37











          • hmm i tried, still let me submit eventhough I had only 1 character in the message field

            – Terry
            Nov 2 '13 at 18:37












          • use an hml5 validation polyfill to make sure it works in all browsers.

            – dandavis
            Nov 2 '13 at 18:51











          • it does not validate, and does not work. I had it as "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> " but it still let me submit only 1 character. any idea how? I just want it so if you enter less then 3 characters it wont let you post

            – Terry
            Nov 2 '13 at 18:53













          0












          0








          0







          Set min-length



          pattern=".5," --> 5 characters minimum


          set both min-length and max-length



          pattern=".5,100" --> 5 characters minimum and 100 maximum .


          Example



          <input type="text" name="test" pattern=".20,100" required >


          to support Html5 in every browser use html5shiv




          Updated after OP's comment

          $('#myform').submit(function(e)
          if($('#message').val().length < 3)
          e.preventdefault();

          );





          share|improve this answer















          Set min-length



          pattern=".5," --> 5 characters minimum


          set both min-length and max-length



          pattern=".5,100" --> 5 characters minimum and 100 maximum .


          Example



          <input type="text" name="test" pattern=".20,100" required >


          to support Html5 in every browser use html5shiv




          Updated after OP's comment

          $('#myform').submit(function(e)
          if($('#message').val().length < 3)
          e.preventdefault();

          );






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 2 '13 at 18:56

























          answered Nov 2 '13 at 18:31









          Tushar GuptaTushar Gupta

          42.6k188190




          42.6k188190







          • 1





            like so? "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> "

            – Terry
            Nov 2 '13 at 18:36











          • @Terry yeah ..!!

            – Tushar Gupta
            Nov 2 '13 at 18:37











          • hmm i tried, still let me submit eventhough I had only 1 character in the message field

            – Terry
            Nov 2 '13 at 18:37












          • use an hml5 validation polyfill to make sure it works in all browsers.

            – dandavis
            Nov 2 '13 at 18:51











          • it does not validate, and does not work. I had it as "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> " but it still let me submit only 1 character. any idea how? I just want it so if you enter less then 3 characters it wont let you post

            – Terry
            Nov 2 '13 at 18:53












          • 1





            like so? "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> "

            – Terry
            Nov 2 '13 at 18:36











          • @Terry yeah ..!!

            – Tushar Gupta
            Nov 2 '13 at 18:37











          • hmm i tried, still let me submit eventhough I had only 1 character in the message field

            – Terry
            Nov 2 '13 at 18:37












          • use an hml5 validation polyfill to make sure it works in all browsers.

            – dandavis
            Nov 2 '13 at 18:51











          • it does not validate, and does not work. I had it as "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> " but it still let me submit only 1 character. any idea how? I just want it so if you enter less then 3 characters it wont let you post

            – Terry
            Nov 2 '13 at 18:53







          1




          1





          like so? "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> "

          – Terry
          Nov 2 '13 at 18:36





          like so? "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> "

          – Terry
          Nov 2 '13 at 18:36













          @Terry yeah ..!!

          – Tushar Gupta
          Nov 2 '13 at 18:37





          @Terry yeah ..!!

          – Tushar Gupta
          Nov 2 '13 at 18:37













          hmm i tried, still let me submit eventhough I had only 1 character in the message field

          – Terry
          Nov 2 '13 at 18:37






          hmm i tried, still let me submit eventhough I had only 1 character in the message field

          – Terry
          Nov 2 '13 at 18:37














          use an hml5 validation polyfill to make sure it works in all browsers.

          – dandavis
          Nov 2 '13 at 18:51





          use an hml5 validation polyfill to make sure it works in all browsers.

          – dandavis
          Nov 2 '13 at 18:51













          it does not validate, and does not work. I had it as "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> " but it still let me submit only 1 character. any idea how? I just want it so if you enter less then 3 characters it wont let you post

          – Terry
          Nov 2 '13 at 18:53





          it does not validate, and does not work. I had it as "<div class='message'> Post: <br> <textarea rows="10" cols="50" name='message' id='message' pattern=".20,100" required></textarea> </div> " but it still let me submit only 1 character. any idea how? I just want it so if you enter less then 3 characters it wont let you post

          – Terry
          Nov 2 '13 at 18:53













          0














          Note that your HTML misses </head>. That said, the "pattern" attribute seems to work :



          <input type="text" required="required" pattern="^[A-Za-z0-9]3,15$" />


          Here is another way of doing this using Javascript. Just put this code into the <head> section, right after $("#datepicker").datepicker(); :



          $('form').submit(function (e) 
          var nameValue = $('[name="name"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(nameValue))
          alert('failure');
          e.preventDefault(); // prevents from submitting

          );


          Here is a demo combining both solutions : http://jsfiddle.net/wared/KbxM8/.



          See also : http://api.jquery.com/submit/




          I've tried something according to your comments :



          $('form').submit(function (e) 
          var value;

          // "message" pattern : from 3 to 15 alphanumerical chars

          value = $('[name="message"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(value.replace(/n/g, '')))
          alert('Wrong value for "message".');
          e.preventDefault();
          return;


          // "name" pattern : at least 1 digit

          value = $('[name="name"]').val();
          if (!/d+/.test(value))
          alert('Wrong value for "name".');
          e.preventDefault();
          return;

          );





          share|improve this answer

























          • Worked great thank you! Now can I use some form of this to MAKE the user submit atleast 1 numeral in the username field?

            – Terry
            Nov 2 '13 at 20:29











          • hold on, I had it working, but now its not. I put [name="name"] as [name="message"] since the name of the text area is message.

            – Terry
            Nov 2 '13 at 21:50












          • hmm? I dont get what you mean

            – Terry
            Nov 2 '13 at 23:46











          • I updated the code in the OP to show what I have, must just be a small error,

            – Terry
            Nov 2 '13 at 23:51











          • Nope, still does not have an effect. I tried putting it in the header, and in the form, neither worked. I'll paste the updated code above, just so you can see what I am doing. Hmm, so weird

            – Terry
            Nov 3 '13 at 18:06















          0














          Note that your HTML misses </head>. That said, the "pattern" attribute seems to work :



          <input type="text" required="required" pattern="^[A-Za-z0-9]3,15$" />


          Here is another way of doing this using Javascript. Just put this code into the <head> section, right after $("#datepicker").datepicker(); :



          $('form').submit(function (e) 
          var nameValue = $('[name="name"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(nameValue))
          alert('failure');
          e.preventDefault(); // prevents from submitting

          );


          Here is a demo combining both solutions : http://jsfiddle.net/wared/KbxM8/.



          See also : http://api.jquery.com/submit/




          I've tried something according to your comments :



          $('form').submit(function (e) 
          var value;

          // "message" pattern : from 3 to 15 alphanumerical chars

          value = $('[name="message"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(value.replace(/n/g, '')))
          alert('Wrong value for "message".');
          e.preventDefault();
          return;


          // "name" pattern : at least 1 digit

          value = $('[name="name"]').val();
          if (!/d+/.test(value))
          alert('Wrong value for "name".');
          e.preventDefault();
          return;

          );





          share|improve this answer

























          • Worked great thank you! Now can I use some form of this to MAKE the user submit atleast 1 numeral in the username field?

            – Terry
            Nov 2 '13 at 20:29











          • hold on, I had it working, but now its not. I put [name="name"] as [name="message"] since the name of the text area is message.

            – Terry
            Nov 2 '13 at 21:50












          • hmm? I dont get what you mean

            – Terry
            Nov 2 '13 at 23:46











          • I updated the code in the OP to show what I have, must just be a small error,

            – Terry
            Nov 2 '13 at 23:51











          • Nope, still does not have an effect. I tried putting it in the header, and in the form, neither worked. I'll paste the updated code above, just so you can see what I am doing. Hmm, so weird

            – Terry
            Nov 3 '13 at 18:06













          0












          0








          0







          Note that your HTML misses </head>. That said, the "pattern" attribute seems to work :



          <input type="text" required="required" pattern="^[A-Za-z0-9]3,15$" />


          Here is another way of doing this using Javascript. Just put this code into the <head> section, right after $("#datepicker").datepicker(); :



          $('form').submit(function (e) 
          var nameValue = $('[name="name"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(nameValue))
          alert('failure');
          e.preventDefault(); // prevents from submitting

          );


          Here is a demo combining both solutions : http://jsfiddle.net/wared/KbxM8/.



          See also : http://api.jquery.com/submit/




          I've tried something according to your comments :



          $('form').submit(function (e) 
          var value;

          // "message" pattern : from 3 to 15 alphanumerical chars

          value = $('[name="message"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(value.replace(/n/g, '')))
          alert('Wrong value for "message".');
          e.preventDefault();
          return;


          // "name" pattern : at least 1 digit

          value = $('[name="name"]').val();
          if (!/d+/.test(value))
          alert('Wrong value for "name".');
          e.preventDefault();
          return;

          );





          share|improve this answer















          Note that your HTML misses </head>. That said, the "pattern" attribute seems to work :



          <input type="text" required="required" pattern="^[A-Za-z0-9]3,15$" />


          Here is another way of doing this using Javascript. Just put this code into the <head> section, right after $("#datepicker").datepicker(); :



          $('form').submit(function (e) 
          var nameValue = $('[name="name"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(nameValue))
          alert('failure');
          e.preventDefault(); // prevents from submitting

          );


          Here is a demo combining both solutions : http://jsfiddle.net/wared/KbxM8/.



          See also : http://api.jquery.com/submit/




          I've tried something according to your comments :



          $('form').submit(function (e) 
          var value;

          // "message" pattern : from 3 to 15 alphanumerical chars

          value = $('[name="message"]').val();
          if (!/^[A-Za-z0-9]3,15$/.test(value.replace(/n/g, '')))
          alert('Wrong value for "message".');
          e.preventDefault();
          return;


          // "name" pattern : at least 1 digit

          value = $('[name="name"]').val();
          if (!/d+/.test(value))
          alert('Wrong value for "name".');
          e.preventDefault();
          return;

          );






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 4 '13 at 6:49

























          answered Nov 2 '13 at 19:07









          leafleaf

          11.3k44169




          11.3k44169












          • Worked great thank you! Now can I use some form of this to MAKE the user submit atleast 1 numeral in the username field?

            – Terry
            Nov 2 '13 at 20:29











          • hold on, I had it working, but now its not. I put [name="name"] as [name="message"] since the name of the text area is message.

            – Terry
            Nov 2 '13 at 21:50












          • hmm? I dont get what you mean

            – Terry
            Nov 2 '13 at 23:46











          • I updated the code in the OP to show what I have, must just be a small error,

            – Terry
            Nov 2 '13 at 23:51











          • Nope, still does not have an effect. I tried putting it in the header, and in the form, neither worked. I'll paste the updated code above, just so you can see what I am doing. Hmm, so weird

            – Terry
            Nov 3 '13 at 18:06

















          • Worked great thank you! Now can I use some form of this to MAKE the user submit atleast 1 numeral in the username field?

            – Terry
            Nov 2 '13 at 20:29











          • hold on, I had it working, but now its not. I put [name="name"] as [name="message"] since the name of the text area is message.

            – Terry
            Nov 2 '13 at 21:50












          • hmm? I dont get what you mean

            – Terry
            Nov 2 '13 at 23:46











          • I updated the code in the OP to show what I have, must just be a small error,

            – Terry
            Nov 2 '13 at 23:51











          • Nope, still does not have an effect. I tried putting it in the header, and in the form, neither worked. I'll paste the updated code above, just so you can see what I am doing. Hmm, so weird

            – Terry
            Nov 3 '13 at 18:06
















          Worked great thank you! Now can I use some form of this to MAKE the user submit atleast 1 numeral in the username field?

          – Terry
          Nov 2 '13 at 20:29





          Worked great thank you! Now can I use some form of this to MAKE the user submit atleast 1 numeral in the username field?

          – Terry
          Nov 2 '13 at 20:29













          hold on, I had it working, but now its not. I put [name="name"] as [name="message"] since the name of the text area is message.

          – Terry
          Nov 2 '13 at 21:50






          hold on, I had it working, but now its not. I put [name="name"] as [name="message"] since the name of the text area is message.

          – Terry
          Nov 2 '13 at 21:50














          hmm? I dont get what you mean

          – Terry
          Nov 2 '13 at 23:46





          hmm? I dont get what you mean

          – Terry
          Nov 2 '13 at 23:46













          I updated the code in the OP to show what I have, must just be a small error,

          – Terry
          Nov 2 '13 at 23:51





          I updated the code in the OP to show what I have, must just be a small error,

          – Terry
          Nov 2 '13 at 23:51













          Nope, still does not have an effect. I tried putting it in the header, and in the form, neither worked. I'll paste the updated code above, just so you can see what I am doing. Hmm, so weird

          – Terry
          Nov 3 '13 at 18:06





          Nope, still does not have an effect. I tried putting it in the header, and in the form, neither worked. I'll paste the updated code above, just so you can see what I am doing. Hmm, so weird

          – Terry
          Nov 3 '13 at 18:06

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19745339%2fmin-length-for-text-area-in-my-form%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page