I try to validate the Input in my website because of Cross-Site-Scripting-Attacks!
<form name="SearchInput" class="form-inline filterForm" method="post" action="/annoncen/" onsubmit="validateMyForm();">
<input type="text" name="searchWord" class="form-control form-search left" id="formGroupExampleInput" placeholder="Text" onkeyup="inputKeyUp(event)"/>
<input type="text" name="searchLoc" class="form-control form-search right" id="formGroupExampleInput" placeholder="Place" onkeyup="inputKeyUp(event)"/>
<button type="submit">search</button>
</form>
I use the validate() plugin to prevent the user put a script in the input field
function validateMyForm(){
var text_value = $('#formGroupExampleInput').val();
if(text_value!=='/^[a-zA-Z ]*$/') {
alert("Enter Some Text In Input Field");
event.preventDefault();
}}
but every time I get text_value =""
!!! What am I doing wrong