kelvint 2002/12/03 03:47:26 Modified: contributions/javascript/queryValidator luceneQueryValidator.js Log: Added a flag for wildcard case-insensitivity. Revision Changes Path 1.2 +16 -7 jakarta-lucene-sandbox/contributions/javascript/queryValidator/luceneQueryValidator.js Index: luceneQueryValidator.js =================================================================== RCS file: /home/cvs/jakarta-lucene-sandbox/contributions/javascript/queryValidator/luceneQueryValidator.js,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- luceneQueryValidator.js 8 May 2002 15:56:58 -0000 1.1 +++ luceneQueryValidator.js 3 Dec 2002 11:47:26 -0000 1.2 @@ -1,12 +1,13 @@ -// -// JavaScript Lucene Query Validator // Author: Kelvin Tan ([EMAIL PROTECTED]) -// Date: 10/04/2002 +// Date: 03/12/2002 +// JavaScript Lucene Query Validator +// Version: $Id$ // validates a lucene query. // @param Form field that contains the query function doCheckLuceneQuery(queryField) { + var wildcardCaseInsensitive = true; var query = queryField.value; if(query != null && query.length > 0) { @@ -20,7 +21,7 @@ } // check parentheses are used properly - matches = query.match(/^([^\n()]*|(\(([a-zA-Z0-9_+\-:()\" ]|\*)+\)))*$/); + matches = query.match(/^([^\n()]*|(\(([a-zA-Z0-9_+\-:()\" ]|\*)+\)))*$/); if(matches == null || matches.length == 0) { alert("Invalid search query! Parentheses must contain at least one alphabet or number. Please try again.") @@ -34,7 +35,7 @@ alert("Invalid search query! '+' and '-' modifiers must be followed by at least one alphabet or number. Please try again.") return false; } - + // check that quote marks are closed matches = query.match(/\"/g); if(matches != null) @@ -46,13 +47,21 @@ return false; } } - + // check ':' is used properly - matches = query.match(/^(([^\n:]*|([a-zA-Z0-9_]|\*)+[:]([a-zA-Z0-9_()"]|\*)+))*$/); + matches = query.match(/^(([^\n:]*|([a-zA-Z0-9_]|\*)+[:]([a-zA-Z0-9_()"]|\*)+))*$/); if(matches == null || matches.length == 0) { alert("Invalid search query! Field declarations (:) must be preceded by at least one alphabet or number and followed by at least one alphabet or number. Please try again.") return false; + } + + if(wildcardCaseInsensitive) + { + if(query.indexOf("*") != -1) + { + queryField.value = query.toLowerCase(); + } } return true;
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>