我需要你的帮助。
我需要想出一个 javascript 函数,它可以简单地检查输入到文本框中的字符串,该文本框基本上可以确定 SQL 运算符
例子:
var field1 = document.getElementById('field1').value
var field2 = document.getElementById('field2').value
var field3 = document.getElementById('field3').value
function validate(textbox) {
var operator
if ('%' is the first character placed before and after the value) { then operator = LIKE }
else if ('%' is the first character placed before the value) { then operator = LIKE }
else if ('%' is the last character placed after the value) { then operator = LIKE }
else { operator equals "=" } //default
alert(operator)
}
实际功能示例:
validate(field1)