1

here is the function from the source code

function dosubmit() { if (getObj("Frm_Username").value == "") { getObj("errmsg").innerHTML = "Username cannot be empty."; getObj("myLayer").style.visibility = "visible" ; return; } else { getObj("LoginId").disabled = true; getObj("Frm_Logintoken").value = "3"; document.fLogin.submit(); } } 

i want to get the value of getObj("Frm_Logintoken") as i can't pull the value from #Frm_Logintoken

using document.getElementById("#Frm_Logintoken") this gives me null

because Frm_Logintoken only gets it's value when i click submit .

<input type="hidden" name="Frm_Logintoken" id="Frm_Logintoken" value=""> 

full page code

i found this online /getObj\("Frm_Logintoken"\).value = "(.*)";/g but when i run it ... it gives me the same line again ! it's full code

another regular expression i found but don't even know how to use it

Example of a regular expression to search: before_egrep='N1:getObj("Frm_Logintoken").value = "(\w+)"'

Here, N1 is assigned the value of the back reference - the expression in parentheses. \w + denotes the main compound characters, this is a synonym for "[_[:alnum:]]". Once again - pay attention to the brackets - this is the back link. At the same time, there are also parentheses in the source code fragment - they need to be escaped

i am trying to make an auto login script that works in the background like it

doesn't show the user the login form page but the only the page after it

and i have found this code online too but don't know what's about it contains xhr .

the line that Attracted my attention is

/getObj\("Frm_Logintoken"\).value = "(.*)";/g 

when i run it ... it gives me the line again !

some notes :

i have tried document.getElementById("Frm_Logintoken").value but it gives me empty "" because

Frm_Logintoken only gets it's value when i click submit .

the page will not even accept the correct password if the Frm_Logintoken token value isn't the same as one in the page.

the Frm_Logintoken is a token generated by the page and it basically increment by one on each successful login.

2 Answers 2

0

I'm not so sure about suggestion of an expression for helping or ameliorating to help solving your problem, yet if we wish to extract certain attributes and values from the proposed input tag, we would be likely starting with an expression similar to:

name="(.+?)"|id="(.+?)"|value="(.+)?" 

which uses alternation to simultaneously collect values of certain attributes, if so would be desired.

Demo

RegEx

If this expression wasn't desired and you wish to modify it, please visit this link at regex101.com.

RegEx Circuit

jex.im visualizes regular expressions:

enter image description here

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

4 Comments

thanks but i don't want the value from the input tag but from the function dosubmit() tag
this line exactly getObj("Frm_Logintoken").value = "3";
Wouldn't this just match all the lines that doesn't contain new lines ? any way can we get a one to match this getObj("Frm_Logintoken").value = "3"; ?
i found that getObj\("Frm_Logintoken"\).value = "(.*)"; works as expected but how can i get the value of the result group 1 ?
0

To get your value you might use a capturing group ([^"]+) and a negated character class:

\bgetObj\("Frm_Logintoken"\)\.value = "([^"]+)"; 

Regex demo | Javascript demo

For example:

let str = `getObj("Frm_Logintoken").value = "3";`; let pattern =/\bgetObj\("Frm_Logintoken"\)\.value = "([^"]+)";/; console.log(str.match(pattern)[1]); //3 

13 Comments

your answer is good but i think i asked the wrong question ... i need to make an auto login script so i need the script to find the value for me .. so let str isn't possible in my case ! what should the title of my question be ?
@minanageh Not sure where your jacascript is located but perhaps you could check this page to get the html of the current page instead of let str.
ok i will check it .. my java script should be located on a local web server with the ip of something just like 192.168.1.22
i got how to make it work if it's the same page let str = document.documentElement.innerHTML then your code let pattern =/\bgetObj\("Frm_Logintoken"\)\.value = "([^"]+)";/; console.log(str.match(pattern)[1]); but if it's from another page ?
That depends where that page is. If it is on the same domain and allowed you might try an asynchronous call to get the page and get that html.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.