design
November 20, 2019, 10:27am
1
Like
<form action="">
.prop('action', 'https://www.theaction.com'); // 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?
Thanks!
snigo
November 20, 2019, 10:50am
2
Attributes, like action
are accessible in JavaScript:
const form = document.querySelector('form');
console.log(form.action);
1 Like
design
November 20, 2019, 10:59am
3
I understand this get the value. But how check is contain https:// or not or just have there action=“changeme”?
Thanks!
snigo
November 20, 2019, 11:29am
4
You can do it with regex:
/https?:\/\//.test(form.action);
1 Like
design
November 20, 2019, 2:47pm
5
Thank you by the way is not that easy for me to understand.
Please take a look this?
http://jsfiddle.net/zormh4ck/6/
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?
Thanks!
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