I'm very new to developing Safari Extensions and I don't know any java, css or html.
I've been searching round the web for a way to interact with a website using javascript injection. Specifically, I wish to fill out two forms; a username and a password and then press the 'login' button.
I've learned that I need to use something like document.getElementById() and .click and .value, but I really don't know how to connect the dots.
Any help is much appreciated!
Kind regards, Tokke
I will assume that when you say two forms, username and password you mean two text inputs, and then submit the form.
What you should do, is:
Select each text input and change its value attribute.
Submit the form
Could be done with the following code, assuming that your form has an id="my-form", your username input has id="username" and your password input has id="password".
document.getElementById("username").value = "myusername"; // Select and fill username input
document.getElementById("password").value = "mypassword"; // Select and fill password input
document.getElementById("my-form").submit(); // Submit the form
Related
Using Adobe Acrobat Pro
I am filling out a form that will be used by a variety of people, each with their own team lead. I want people to be able to fill out the form, type in the email of their team lead, and then have a submit button that will submit the form to that email.
Does anyone know what javascript I need to write to accomplish this?
I tried the Submit form function of the adobe acrobat button, but it doesn't allow me to customize the Mailto: form.
Edit: I found Javascript that lets users fill in a text entry field that will then be the subject of the body once the users click the submit button. Can someone who is more savvy than I rework this so that the email address is the one based on the user's entry?
Where "MyTextField" is the earlier user text field for the subject:
var customSubject = this.getField("MyTextField").value;
var mailtoUrl = "mailto:studiosupport#qoppa.com?subject=" + customSubject;
this.submitForm({
cURL: mailtoUrl, bPDF:true
});
I'm trying to learn a bit about code as I look through this. Why would this workaround not work?
var customSubject = Tomato;
var mailtoUrl = "mailto:this.getField("MyTextField").value?subject=" + customSubject;
this.submitForm({
cURL: mailtoUrl, bPDF:true
});
i want two concatenate the Username + Email Domain , On click OK button
and Display result in Below Full Email field.
Javascript Code to do that please help
In the Full Email field, add the following JavaScript to the mouse up action. You may need to edit the field names to match yours.
this.getField("Full Email").value = this.getField("username").value+this.getField("Email Domain").value
I'm using a form that has 3 parts, login, forgot password and registration. The initial view is the login form, but can be changed to the forgot password or registration form, which replaces the initial view by using JS.
I'm looking to post back to the page if validation isn't met. This seems to be working fine, and the field repopulates itself. However I can't get the right form to load when posted back.
For example, if the user is filling out the forgot password form, and fills in an invalid email address, the message at the top of the form will be correct, however the form that will appear is the default login form. Once the user clicks on the forgot password button, JS kicks it over to the forgot password form, and has the users invalid email address re-populated. Each form has a unique "form_type" hidden variable to differentiate between the three, so I can use this to check then load the right one. Ideally I would like to keep this as 1 page and use JS to swap between the three if possible.
I don't know how to get it to load the right form once posted back. It's using the below code to change between the forms. How do I link to the right form when posting back.
<a href="javascript:;" id="forget-password">
<a href="javascript:;" id="register-btn">
I'm not good with JS at all, and I think this is the issue. The front end and JS is all created by a third party, it's "Metronic" theme. Let me know if I need to include any JS. If it makes a difference, although the logic should be the same, I'm using codeigniter too.
EDIT All the functionality to swap between the forms is there, I just need it to POST back to the right form. This is what I have so far, if you click on the forgot password and enter an email address that is longer than 5 characters, you'll see what I mean. I obviously didn't ask this very well...
Once the user submits, and the form is posted back with errors, I need right form to pop up, rather than the default for the page. The tags above are the links used to swap between the different forms.
May be you can try on posting back to view also bring one extra variable say 'show_form'
in that show_form have you form id and based on that do jquery hide/show method
like $('#' + show_form).show() and other 2 hide.
you can try this.
I'm not sure I understand exactly what you're asking.
Do you need to have 3 forms in the same page and swap between them with JS?
If so, give each of the forms a unique ID and have 2 forms with display: none. then all you have to do (assuming you do not want to use jQuery) is just to change the style.
HTML:
<form id="first_form" class="form-visible">
...
</form>
<form id="second_form" class="form-gone">
...
</form>
<form id="third_form" class="form-gone">
...
</form>
CSS:
.form-visible
{
display: inline;
}
.form-visible
{
display: none;
}
JS:
function swapForms(id)
{
Swap-between-forms
}
differentiate the form with some variable . for example after submission form you can post back errors in variable name like if the submitted form is forgot password means define the variable name is $forgot like that. in view file check if(isset($forgot)) then set it's style as display block .
I am trying to stop spammers submitting Hyperlinks on a text box for a form.
The form asks the user to input their Full Name, Email Address, Telephone Number and then there is a box for them to enter a message. The Email Address and Telephone Number prevent hyperlinks because the validation specifies that the Phone can only consist of numbers, and the Email must contain an #.
Is there a way using Javascript combined with ASP that I can stop a form being submitted if it contains (http) or (www).
I tried the following without success
<script type="text/javascript">
function Validate(x, y) {
str = (document.getElementById('Messagetxt')).value;
if (str.match(/(http)(www)([\<])([^\>]{1,})*([\>])/i) == null) {
y.IsValid = true;
}
else {
y.IsValid = false;
}
}
</script>
Which is linked to a Custom Validator for the text box. When ever I enter http, www, or html tags < >, which I am trying to prevent, the form submits but presents an error page.
Usually what you're experiencing aren't hackers but bots passing over your site. I would recommend a more simplistic approach (maybe as well as) of tricking the bots into filling a hidden field.
Put a textbox on your form with a style set to display: none;, along with a completely unrelated id, something like catchUnreal. Check the value of catchUnreal on your server side code to see if it has a value. If it does, it is highly likely that a bot has completed your form - don't submit the answer:
<input type="text" id="catchUnreal" class="dontDisplay" />
...
...
<%if Request.Form("catchUnreal")<>"" then
'Do my stuff
end if%>
(If you catch my drift).
-- EDIT --
Apologies - I wasn't reading properly.
The process above can also be applied using JavaScript by simply checking the hidden box value using JavaScript:
if(document.getElementById("catchUnreal").value<>"") doProcessing();
--Edit --
Another idea is to use the server-side command server.HTMLEncode(string) which will remove any unwanted tag encodings.
I'm new to this kind of stuff so sorry if this is not possible or does not make any sense. Im making a app where someone puts in there username into the form and when they press enter a popup says words but then i want for after they press ok it puts the username into the form ---- instagram://user?username --- where it says username thats where i want the username from the form to go then it will go there. sorry if this doesnt make sense or is not possible wondering if it is
You want to set your form action to GET. I believe that is what you are trying to ask.
<form action='[url submitting to]' method='GET'></form>
Using jQuery, if this is the language you are working with, you could prevent the submit and get the username field and add it to url and load this page.
//html
<form>
<input id="username">
</form>
//javascript
//the submit event is captured
$('form').on('submit', function(e){
//the event is passed in on the function and is used to prevent the
//default action so we can perform some further action
e.preventDefault();
//here we grab the value of the the #username text field
var user = $('input#username').val();
//here we are loading the instagram page based upon the user's textfield
window.location = 'instagram://user?' + user;
});
Is this what you are looking for?