RegEx in JavaScript and C # for text validation

2

In a Asp.Net WebForms plication application, I have a TextBox that I need to validate if it contains any excerpt where < is followed by any character except whitespace.

For example:

Nesse texto pode existir < com espaço. Mas não pode <. <+ <? </ <\ <A <0 <*

In this case, RegEx should find eight results = <. , <+ , <? , </ , <\ , <A , <0 (containing the space) . Where <* represents any alphanumeric character and < any number.

This RegEx will be used in the A event of the HTML page via JavaScript and in 0 in Asp.Net.

Thanks for the help!

    
asked by anonymous 25.05.2017 / 21:47

1 answer

1

I do not know if I understood very well, see if this example helps.

<input type="text" id="input_teste" name="input_teste"/>
<input type="submit" value="Testar" onclick="valida_teste()"/>
<script type="text/javascript">
function valida_teste()
{ var filter_test = /< /g;
  if(!filter_test.test(input_teste.value))
  {   alert("O valor : " + input_teste.value + "é incorreto");
  }else
  {   alert("O valor : " + input_teste.value + "é correto");
  }
}
</script>
    
25.05.2017 / 22:05