I'm working on chrome extension for automating google forms submission.There is an <input> field of type date which is a required field. I'm setting the date programmatically before submitting it. But google forms assumes the date field is not set since I didn't edit it manually, and it's giving a *Field is required error while submitting. I'm able to submit if I set the date manually but I want it to be automated and programmatic.
I tried checking if there is a property on the input element which google forms checks to see if the value is set or not, but no luck. I believe frameworks like Angular/React have properties like dirty/pristine for this purpose but I need this in vanilla JS. I'm looking for a property which I'll be able to set in the javascript of the chrome extension.
I also want to note that a solution like making the input field not required won't be possible since the form is external and I can't alter the form in any way. I only have access to the chrome extension source code.
Related
I tried to scrape a website just for learning purposes. I encountered serious form security: I tried to enter the form value using
element.value = "some text". The value appeared inside the input field but when I hit submit button it disappeared and the form got submitted with no value for the input field. My question is,
what type of security is this?
what i can do bypass it?
I tried various solutions such as using jquery to send keys and billiteRange library also tried to dispatch keyboardEvent but nothing works for me. I have been trying for the last 5 days but I've had no luck with this. Please guide me I want to do this.
To my knowledge, there is (currently) no browser side security on a javascript/html level. The best thing a website can do on that level to protect a form from any injected javascript code, is to hide a key (maybe an anti-csrf key) and use it when submitting the form.
On any other case (when there is no key or when you can access and read the key) you can just re-create the hole form and submit it, or even just fake the request to the server. Thus, there is no point in developing codes to protect forms, unless you want to hide the way you generate data that you will send to the server (but, I don't consider this a protection).
In your case, it seems that the javascript code that handles the submission of the form unintentionally or intentionally blocks your attempts to submit the form. This may be due to a validation function that does not fire (most probably). For example, onchange event does not fire when you change the value of an input.
You can see all the events on the form and its inputs from the developer tools of your browser and figure out how the webpage handles the form, but the easiest way to fool the webpage is to fake the hole request.
Nice Answer by GramThanos you helped me a lot it's really a nice explanation, helped me to break it.
Just
use
var event = new Event('eventName', {bubbles: 'true'});
element.dispatchEvent(event);
I’m new to both Dynamics 365 and javascript.
By now users when have to fill an address form write values manually, therefore for the same region we have values like: Lombardia, LOMABARDIA, lomb, Lombadia, etc...
I can't create custom fields because address fields are grouped into composite field and are used for outlook sync.
So i think the right way is create a javascript mask that paste the choosen value in the free text address field, but here is my biggest problem, how to set that mask...
Questions:
Is this the best practice? if not what is?
I am able to create javascript's list and get/set value from crm, but i dont know how to build it over a free text field, any help?
You should consider address resolution API, you will then be able to split the selected address that will be in a standard format. Try to check out Experian or even the google API, you can build a custom web resource, hook up the JS that will do address resolution for you, on selection split the values in the composite fields.
Rather than "build it over a free text field", which is unsupported, you can build your own custom HTML web resource and add that to the form.
As this document points out, you will need to use parent.Xrm.Page to reference the form - e.g.:
var customerRef = parent.Xrm.Page.getAttribute('customerid').getValue();
This forum indicates that although Xrm.Page is deprecated in v9, it is still valid (for now) to use parent.Xrm.Page from a custom web resource.
Also, please note that to enable accessing the form you should include
<script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script>
in your custom web resource.
Let me say this first: I'm not the best in HTML, Javascript or Angular.js
I am using Swift 4 and iOS WKWebView in Xcode to go to specific commercial websites and when a user saves his login information to their iOS device (email and password), it populates those fields and submits. I know there are other options for autofilling fields, but I need to do it this way given the project I'm working on.
I autofill the login by using the textfield's ids like this:
webView.evaluateJavaScript("document.getElementById('email').value = 'example#email.com';", completionHandler: nil)
This method works with basic forms, but with more complex forms it seems (it's using AngularJS Form Validation I believe), you can't just do an autofill and push submit. It'll say this:
I noticed that if you type then delete a random letter into each field after they have been autofilled, the form recognizes the fields as being filled correctly. I think it's because they have the fields as being "required," and normally an input/change event occurs on the website to recognize input in the textfields (just a guess).
And if that's the case, then would I need to locate the specific event(though I've tried and am having trouble locating it in the html) or would I be able to fire off a synthetic event(?) somehow using the "evaluateJavaScript" method?
If anyone could help me with this issue, I would seriously appreciate it.
Is it sufficient to restrict user input value by setting maxlength only? Lets say I have this code:
<input type="text" id="foo" maxlength="12">
Is there any possibility that user still can (in any valid or invalid way) insert value more than 12?
When we have set the maxlength, is it usefull or useless to validate it once again using javascript or maybe at the backend (servlet, etc)?
Is it sufficient to restrict user input value by setting maxlength only?
No
Is there any possibility that user still can (in any valid or invalid way) insert value more than 12?
Yes
When we have set the maxlength, is it usefull or useless to validate it once again using javascript or maybe at the backend (servlet, etc)?
You should validate, and preferrably on the backend.
That's because you don't necessarily need a browser to pass data to the server. There are other client software, like REST testers, curl, wget, tamper data and similar software that can fire requests directly to the server, all of which bypass your maxlength attribute and JS validations.
So if you want fast validation so that the user gets a snappy, interactive response, your maxlength and JS validations does that job. But you should do a second validation when the data is passed to the server, this time for security.
It is all upon you.
Choose your datatype allowing only 12 values in database.
You job on client side is done after validation but database won't be saving values more than 12.
Hi
I have an MVC3 appliocation and using client side validation and find it to be very usefull.
I am having 2 issues while using it.
-One is there any possiblity of Required filed dependency as it there for Compare
eg: If the value of a particular filed say status is="Test" then the value of other say status done field must be not blank otherwise it can be blank.
- I am having a dropdown say state .If its value is "Other" then need to make a textbox visible say "other state" .For know I am using javasript to make it visible.
I donot want to use javasript for that. Can this be performed without using javascript.
You need to write your own custom compare attribute or simply use javascript. Nothing is built in that will do this for you. The other option is to provide server side validation in your controller method where you check this situation and if it fails use ModelState.AddError to give a custom validation error.