0
votes

I have 6 different branch dropdowns which are a list of peoples names. When a name is chosen from one of the drop downs it will be prefilled into a textbox that I have set to hidden and readonly like so

<div id="employeechosen" class="form-group">
    <input type="hidden" name="chosen" id="chosen" class="form-control" required="" readonly>
</div>

In some of these lists are names that I do not want to allow and I remove them from the list using jquery like so:

$("#DES option[value='David']").hide();
$("#DES option[value='Vicki']").hide();

What can I do to stop people from being able to enter anything they want beyond this? All a user would have to do is hit f12 and change input to text and delete readonly and proceed to do what I do not want them to able to do.

What is the best way to lock down a text box to not be compromised?

What could I write in coldfusion to check for those names upon submit and stop the form from processing instead of carrying on with the password change?

JQUERY

$(document).on('change', '#chosen', function() {

    var value      = $(this);
    var anyname    = $('#DES, #DLO, #LR, #NR, #PS, #TRG');

    if (value.val() === anyname.val()) {
        alert('true');
    } else {
        alert('Try again and you will be fired...');
        anyname.val('');
        value.val('');
    }
});

I know how to do this client side version with jquery but anyone really trying to crack it client side will be able to do so. How do I do this server side with Coldfusion?

Any help would be greatly appreciated!

What iv tried but is obviously not correct:

<cfif isDefined("form.submit")>
            <cfif form.chosen eq VickiH>
                <cfoutput>true</cfoutput>
             <cfelse>
                <cfoutput>false</cfoutput>
             </cfif>
        </cfif>

Why does nothing display when I hit the submit button?

1
If all you need to "secure" is any choice from a defined list of names, you could have check against that list of allowed names on the server side easily with a simple listFindNoCase(). - Henry
If your use case it to only allow the user to change their own password, then you should check the user they are setting matches with the user credentials stored in the Session - Henry
The best way to lock down a textbox is to not have one. Given your selects, are they not redundant? - Dan Bracuk
"I cant just make a list of names and make sure those few are not allowed to go through" why not? - Henry
What you tried above is completely off because you are trying to combine JavaScript and ColdFusion code. The fact that you have 6 dropdowns suggests that there might be better approaches available. What's the overall objective? Is it to allow someone to change someone else's password? - Dan Bracuk

1 Answers

2
votes

Two ways:

A) Don't give those select options. This is the easiest.

B) Instead of a textarea, use ajax to populate an html element. With each ajax call use cfml to clean the data. More complicated, but you have more control over the situation.