1

I have the following form element I need to disable from accessing via the mouse using purely CSS. I do not have access to the form element to disable by editing the form input markeup, I only have access to the CSS style sheets.

<input type="text" name="rs:def:website" size="48" maxlength="64">

I'm attempting to use the pointer-events:none to disable the element from being able to accept input. I need to make sure I don't disable other text input.

This is what I've tried with no luck. Any suggestions?

.rs:def:website .input{
  pointer-events: none;
}
5
  • 3
    Why use pointer-events instead of the disabled or readonly attributes? Commented Aug 21, 2017 at 16:46
  • 1
    The dot notation is for class selector, but you try to address the element by an attribute different from class. Also, space in the selector means that the second part is the descendant of the first one, but you have a single element. Have you tried input[name="rs:def:website"] instead? Commented Aug 21, 2017 at 16:48
  • Possible duplicate of How to disable all div content Commented Aug 21, 2017 at 16:50
  • 2
    Keep in mind that you still be able to access the field with your tab key. Commented Aug 21, 2017 at 16:51
  • pointer event is not meant to disable the input it will just prevent from clicking the element, you can still focus the input by using the keyboard by pressing tab button and then you can input data. Commented Aug 21, 2017 at 16:58

3 Answers 3

2

Here is the correct CSS selector:

input[name="rs:def:website"] {
  pointer-events: none;
}
<input type="text" name="rs:def:website" size="48" maxlength="64">

As noted by other answers, this is not a foolproof way to prevent users from editing this input.

Sign up to request clarification or add additional context in comments.

1 Comment

You can still tab to it
1

It's not possible with pure CSS. pointer-events: none; might work in some cases, but you can still Tab through.

You will need to change the actual HTML. Add disabled, either directly in the HTML-file or via Javascript.

<input type="text" name="rs:def:website" size="48" maxlength="64" disabled>

1 Comment

Please note that disabled input won't be submitted.
-2

simply use disabled to disable input.

<input type="submit" disabled>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.