I have a content like this
How can I get that xpath to assert in one for both The email field is required. and The Password field is required.
thanks you so much
The simplest XPath to assert both these texts is:
"//*[contains(.,'The Email field is required')][contains(.,'The Password field is required')]"
You can make it more precise by specifying the tag name div
"//div[contains(.,'The Email field is required')][contains(.,'The Password field is required')]"
Related
I have this working code which I'm using to set placeholder values for username and password fields:
<script>document.getElementById("user_login").setAttribute("placeholder","Please enter your Email Address");</script>
and
<script>document.getElementById("user_pass").setAttribute("placeholder","Please enter your Password");</script>
Now I'm trying to apply this to a 3rd box which has the input ID #memb_password_send-1-email-input but this isn't a straight up element, it's an input field and using this ID (as above) obviously doesn't work.
Here is a picture of console:
What would be the correct way to target this field with placeholder text?
Same method used to provide placeholder for username and password fields would work in this case as well as those are input fields as well. Just make sure that when you are writing this code in in-line script, do this after that input box has rendered i.e. after it's markup so that element is available to get selected.
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 just have one quick question, how do I check if my input contains some mark, like "#"?
I can submit my form under 5 conditions and one of them is that my email input has to contain "#" mark, but I can't find any info how to do this!
You could use
inputValue.indexOf('#')
See here for more details
http://www.w3schools.com/jsref/jsref_indexof.asp
I have to validate an input field, but I have problems when the user copy and paste something inside the input
This is my code
<input type="text" ng-change="calculate()" ng-pattern="coordsPattern" ng-model="from" class="input-coords" placeholder="(x|y)">
where the coordsPattern is:
$scope.coordsPattern = /^\(?\-?\d{1,3}\|\-?\d{1,3}\)?$/;
the input can take
(158|158)
-158|158
(-158|158
.....etc
but when the user copy and paste the same thing from a different page, depending on browser to browser, the input looks like (158|158) but the pattern is invalid because when copying there are hidden tabs or spaces between chars. for example
((tab)(tab)158(tab)|(tab)(tab)-158(tab)
but in the input text looks like (158|-158 so for the user is a valid input
the input is valid (because in the calculate() function I clean the input from spaces and tabs) but invalid with that pattern and angular doesn't execute the calculate() function.
this one is a copy&paste text which includes hidden tabs
(-91|-18)
Thank you
EDIT
this is the var_dump of the string
string '(â€-â€91‬‬|â€-â€18‬‬)' (length=33)
it contains special chars! neither tabs or spaces!
maybe I have to find a different solution to validate the input...
$scope.coordsPattern = /^\s*?\(?\s*?\-?\s*?\d{1,3}\s*?\|\s*?\-?\s*?\d{1,3}\s*?\)?\s*?$/;
This should match the expected input even when there are whitespace characters inserted.
in my form fields i've got watermark text that disappears when the user is typing something in them.
but then, i cannot use jquery validation plugin http://docs.jquery.com/Plugins/Validation#Example for checking that the user has typed something in the fields cause in either way, they will contain text.
so how can i validate that the user type something when they already contain watermark text and the plugin will assume they are filled.
You could store the watermark text for each field somewhere (For example the rel attribute of the element, or in the title if the watermark text is somthing like "enter your name here", or in a custom JS array for 100% clean and valid HTML) and write your own validation method that checks whether the field's content is equal to the default value.
See Plugins/Validation/Validator/addMethod on how to implement your own validation methods.
you must use addmethod:
jQuery.validator.addMethod("watermarkmethod", function(value, element) {
return this.optional(element) || value != 'your watermark text';
}, "Please do not leave empty");