-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move validation from JavaScript to JSP #196
Comments
So I've been struggling with this for the last week, and maybe putting something here is the best way to try to solve the issues I'm running into. I've tried to get the "pattern" attribute into the JavaScript with the .attr("") thing in the validate code, and as far as I can tell it's successful at getting that string into the JavaScript (I can tell it to output that string to an alert and it does just fine). However, when I try to test the user input against the regex made with the string, it's not getting the regex correct. The most common behavior I've seen is it only thinking "&" is an invalid character and accepting everything else. When I hard-code the original JavaScript regex (the one we want to replace) directly into the code in job.js, it works perfectly fine. When I move that regex out into the JSP form into the attribute, however, it stops working completely. Is there a way to circumvent this problem completely by just having the HTML check the pattern and get that result into the JavaScript somehow for feedback to the user? The "pattern" attribute is supposed to do this, but so far as I can tell the only way to check whether HTML input is valid is check it against everything we specify in the HTML, at which point the JavaScript won't be able to tell what's wrong with the input and would have to give a super vague feedback to the user about an invalid entry. |
I think Did you push some commits that I can look at to see why the regex does not work when it comes from the JSP? I wonder if we need to escape ampersands before outputting them; maybe I can help with this, if I can see your code. Maybe open a pull request and prefix the title with |
Instead of hardcoding these regex validations in JavaScript, we should embed them in our JSP forms referencing the constants in
R.java
. This way, we are not repeating the same expression in multiple places in our code, and updating the expression in one place will update it everywhere.StarExec/WebContent/js/master.js
Lines 322 to 327 in ec23f40
StarExec/src/org/starexec/constants/R.java
Line 171 in bbd4f6b
The text was updated successfully, but these errors were encountered: