php - Textarea regular expression -


i need test textarea accept following.

new line \n, space \s, a-za-z, 0-9,? $@#()'!,+-/=_:.&€£* , %.

edited: far tried:

var regx = a-za-z0-9?$@#()'!,+\-=_:.&€£*%\s ;  /*don't know method checking regular expression   so, method validate_regex check/match */  regx.validate_regex(my_textbox_value); 

please answer how write regular expression using php , jquery.

assuming textbox-id id of textarea

var textboxvalue = $("#textbox-id").val(); var regx = /^[a-za-z0-9?$@#()'!,+\-=_:.&€£*%\s]+$/;  if (regx.test(textboxvalue))     alert("correct"); // alerts else     alert('incorrect!');​ 

try one:

html:

<textarea  id="foo"> </textarea>  <input type="text" id="bar"/> 

js:

var regx = /^[a-za-z0-9?$@#()'!,+\-=_:.&€£*%\s]+$/;  $('#foo').keyup(function() {     if (regx.test(this.value)) $('#bar').val('correct');     else  $('#bar').val('incorrect'); }); 

edited: here updated jsfiddle demo


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -