Hey. There is such a form.

<textarea id="comments-form-comment" name="comment"></textarea> <a onclick="comments.saveComment();return false;" >Отправить</a> 

How to make a check. So that if there is a link or a specific word in the textarea (Например слово тест ) , clicking on the Отправить link will display a message in the warning box. And after that to send the form did not occur.

Here is the full form code.

 <form id="comments-form" name="comments-form" action="javascript:void(null);"> <textarea id="comments-form-comment" name="comment"></textarea> <a href="#" onclick="jcomments.saveComment();return false;">Отправить</a> </form> 
  • Do you have a jquery tag for what purpose? When sending a form, get text from textarea , look for words or links there. What is your problem? - teran
  • @teran i'm in jquery and js is not selenium. Therefore, I do not really understand the logic. - Anatoly

1 answer 1

I will give the general logic how to make search (jQuery)

 function saveComment() { var textarea = $('textarea#comments').val().indexOf('http://') > -1; if (textarea) { console.log('true'); } else { console.log('false'); } } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <textarea id="comments" name="comment"></textarea> <a onclick="saveComment();">Отправить</a> 

  • The text is clear. And how to catch links? - Anatoly
  • same thing, just checking for example http, changed in response - Arsen
  • Hmm, but google.com/q does not catch :) - user207618
  • @Arsen Thank you very much, I'll screw myself up like this. - Anatoly
  • @Other, google.com/q is not a link (as understood by WEB) - Arsen