I have a text box in which I use the blur event to validate text with a regular expression. If this fails, I want the text box to keep focus. I know that in regular javascript you can say return functionName();in the onblur event inside the current html control. Is there a way to do something similar when binding a blur event inside a function $(document).ready(). Or just set the focus to "this". Thanks for the help.
return functionName();
$(document).ready()
$(document).ready(function() {"); $('input:text.sqlValidation').blur(function() {"); var sqlInjectionRegX2 = /...Regex.../; var value = this.value; if (sqlInjectionRegX2.test(value)) { alert('The text you have entered may contain malicious code and can not be submitted.'); this.value = ''; return false; } else return true; }); });
Javascript SQL - (, , ) . !!! . , , . SQL Injection , , , , . , , Javascript ( HTTP-), . , , SQL- .
, return false event.preventDefault() . ; , , Javascript.
return false
event.preventDefault()
, this.focus() . http://docs.jquery.com/Events/jQuery.Event. .
- - javascript, ;
:
var inBlur = false; jQuery('#the_input_element').blur(function(){ if (!inBlur) { inBlur = true; jQuery('#some_other_input_element').focus(); inBlur = false; } });
, , ( jQuery ), -.
$(this).focus();
-?
I think the best way to prevent SQL Injection without overwriting legacy code to use parameters ( this question is now closed) would be to double all the quotes and backslash (replace 'with ''and \with \\).
'
''
\
\\
Please note that I am not an expert on SQL syntax, so I cannot guarantee that this will be impervious.
Source: https://habr.com/ru/post/1719979/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1719974/sending-keystrokes-to-control-in-net&usg=ALkJrhhh_pnEt2WOgUN39NRJZ75MTMLg6QZIP files corrupted by IE - internet-explorerhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1719976/how-do-i-convert-these-coordinates-to-google-map-readable-coordinates&usg=ALkJrhgWsfGKwIOFonfyPQq-NIwIwP_wRQAre languages ββwith a metalinguistic abstraction different than those that use the reflection API? - javamod_wsgi, the wsgi daemon visible behind _both_ http and https - web2pyeXtreme Programming - prototyping as a task? Or reduce the tasks you perform? - agileSaving video from UIImagePickerController to basic data on iPhone OS - iphoneStackOverflowException in LINQ to SQL - .netSQL conversion - LINQ - problem using both Min / Max - sqlHow to merge forward in svn? - branchAll Articles