Skip to content

Instantly share code, notes, and snippets.

@smonff smonff/jsbin.UkIFuRi.css
Last active Dec 24, 2015

What would you like to do?
Search a textarea for a mail address and disable the sform submission button if found
input {
height: 50px;
width: 90%;
#message {
color: red;
<!DOCTYPE html>
<script class="jsbin" src=""></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src=""></script>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
<input type="textarea" placeholder="Ici essaie de mettre une adresse mail"/>
<span id="message">Interdit !</span>
<input id="validate" type="submit" value="Envoyer la purée" />
$('input[type=textarea]').bind('input propertychange', function() {
var checklength = $(this).val().length;
if(checklength > 3){
var text_area_content = $(this).val();
var email_regex = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/i;
if(text_area_content.match(email_regex)) {
$('#validate').attr("disabled", "disabled");
console.log("!!!!! MAIL DÉTECTÉ !!!!!");
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.