i would like to check that whether the field entered in the text field is email or not.If its email field then proceed else show some alert or error.
I don't know how to validate that field.
Please help me out
First add RegexKit to your project.
Import RegexKitLite.h to the class where you want to check the format
NSString *emailMatchstring=#"\\b([a-zA-Z0-9%_.+\\-]+)#([a-zA-Z0-9.\\-]+?\\.[a-zA-Z]{2,6})\\b";
compare this string to UITextField's text.
I think the regular expression can help you.
NSRegularExpression Class Reference
Related
When I enter text into the text field it gets removed.
Here is the code:
String barcode="0000000047166";
WebElement element_enter = _driver.findElement(By.xpath("//*[#id='div-barcode']"));
element_enter.findElement(By.xpath("//html/body/div[1]/div[3]/div[1]/form/div/div/input")).sendKeys("barcode");
Agree with Subir Kumar Sao and Faiz.
element_enter.findElement(By.xpath("//html/body/div[1]/div[3]/div[1]/form/div/div/input")).sendKeys(barcode);
I had a case where I was entering text into a field after which the text would be removed automatically. Turned out it was due to some site functionality where you had to
press the enter key after entering the text into the field. So, after sending your barcode text with sendKeys method, send 'enter' directly after it. Note that you will have to import the selenium Keys class. See my code below.
import org.openqa.selenium.Keys;
String barcode="0000000047166";
WebElement element_enter = driver.findElement(By.xpath("//*[#id='div-barcode']"));
element_enter.findElement(By.xpath("your xpath")).sendKeys(barcode);
element_enter.sendKeys(Keys.RETURN); // this will result in the return key being pressed upon the text field
I hope it helps..
Use this code.
driver.FindElement(By.XPath(".//[#id='header']/div/div[3]/div/form/input[1]")).SendKeys("25025");
It might be the JavaScript check for some valid condition.
Two things you can perform a/c to your requirements:
either check for the valid string-input in the text-box.
or set a loop against that text box to enter the value until you post the form/request.
String barcode="0000000047166";
WebElement strLocator = driver.findElement(By.xpath("//*[#id='div-barcode']"));
strLocator.sendKeys(barcode);
I am using GWT ValeBox with GWT Renderer to show amount with $ as prefix.
Now I want not to allow user to type any thing before dollar sign. I tried various GWT event handlers like ValueChangeHandler and some others but unable to achieve goal.
Still struggling for it. If anybody know good solution for it, please share here.
Regards,
The easiest would be to not include the currency as part of the value, but next to the field.
Alternatively, you could replace the value with a numeric-only value on focus, and reformat it as a currency on blur.
Couple of solutions:
Use a label before the valuebox. Label value will be $ and valuebox will contain the numeric value.
You can use empty text in the valuebox. Empty text will specify user to enter $ value.
I have some problem with autocomplete. And my question is: Can I send my own personally typed text instead object from autocomplete list?
When I send object from list to "person.eamil" it's ok, but
when I send normal text to "person.email" I get null instead my text.
Here is my HTML code:
<md-autocomplete
ng-model="person.email"
ng-disabled="false"
md-no-cache="true"
md-selected-item="person.email"
md-search-text-change="setPersonValidEmail(person, !innerForm.email.$error.email);"
md-search-text="searchText"
md-items="item in people"
md-item-text="item.email"
md-min-length="0"
placeholder="some#one.com"
ng-click="addOurPersonIfNecessary($index);"
name = "email">
<md-item-template>
<span md-highlight-text="searchText" md-highlight-flags="^i">{{item.name}}</span>
</md-item-template>
</md-autocomplete>
Md-selected-item here is expecting an object that is populated in people. Only then it can populate the auto complete. You can pass the text to md-search-text
I found solution. Try to use another autocomplete plugin like this:
https://github.com/ghiden/angucomplete-alt
I'm trying to setup a form where some fields needs to be hidden depending on the user role. I'm doing this in my own module using hook_form_FORM_ID_alter. No problem with common text, email or link fields (e.g. $form['field_companyname']['und'][0]['value']['#type']='hidden'). But for an image field or a multiple value file field the usual way won't work.
Anybody can give me a clue?
I think your going about this the wrong way. Since your limitation is based on roles you can just use the permissions system. Check out field permissions module.
I recommend you to use #access for the element instead of just hiding the field.
For field company name it will go like this:
$form['field_companyname']['#access'] = FALSE;
Could anyone advice on the correct way to retrieve and check the value of a textfield with Zend_Test_PHPUnit_ControllerTestCase? The assert conditions are fine for css selectors, but I cannot see a way of checking that a textfield or other form element is correctly populated? any clues much appreciated!
you should validate data entry with Zend_Validate (which is part of the production code). you then would unit test that the value is retrieved correctly after it was stored in the DB.