How to detect if a form action not contain https://?


<form action="">

.prop('action', ''); // Is to set
.val = "" // If empty

Then something like how to detect if the action property contain https://?

$('form:contains(''https://') or something? But this is for text not for property as I know.

Any idea?


Attributes, like action are accessible in JavaScript:

const form = document.querySelector('form');
1 Like

I understand this get the value. But how check is contain https:// or not or just have there action=“changeme”?


You can do it with regex:

1 Like

Thank you by the way is not that easy for me to understand.
Please take a look this?

Is always give back true? just for a-z so how check https then? This case is need to be false not? As not just a-z contains?


You have a typo on the following line:

var input = $("register").attr("action");

You are missing a # in front of register.

The reason you /^[a-z]+/.test returns true is because if you assign “https:” to the “action” attribute, the regex matches the “https” because your regex is checking if one or more of the first characters are in the character set a-z.

1 Like