Validation field value format - format

I have a field on a form called "PartNumber". What I want to do is: the field value to respect some standard/validation:
digit,digit,digit,letter,digit,digit,digit,digit,digit
So, 3 digits 1 letter 5 digits. Also, I have a "Save" button. If the user enters, for example, 123F45156 and then Save => OK. But if the user enters 1565515156 then Save => a messagebox will appear.
I will appreciate your help! Thanks

#Matches is a better solution, as you can check the precise pattern of characters, digits and punctuation.

You may want to look at this blog entry:
http://www.bleedyellow.com/blogs/texasswede/entry/regular_expressions_in_notes_lotusscript
It explains how to use regexp in Lotusscript. You could simply add a check to the QuerySave event as well as to the Exiting event for the field.

You can put code in the fields input validation event that will check if the value is #IsNumeric and if so #Prompt the user
or you could do it using lotusscript in the query save event. using isnumeric and prompt the user using msgbox()

In the Input Validation formula enter:
#If( #Matches( #ThisValue; "{0-9}{0-9}{0-9}{A-Z}{0-9}{0-9}{0-9}{0-9}{0-9}" );
#Success;
#Failure("Please use format ######### where # is a digit and # is a letter.")
);

Related

Cannot add a number in a text field containing html5 number validation using watir/selenium in Ruby

#broswer.text_field(:id => 'mobile1').set "07888888888"
<input type="number" class="mobileno required" name="mobile_field" id="mobile1">
The first line corresponds to when i am trying to set a number in the text field, but the problem is that when it inserts the number into the text field the zero gets deleted and thus number remaining in the field is just '7888888888' which is not a valid number and thus the validation fails. I have tried using send keys method and even editing the value of the text field but nothing works. Any help is appreciated.
as you said manually it removed 0 from text_filed, You might want to try execute_script to check how application behaves.
#browser.execute_script("$('text_field#mobile1').val('07888888888')")
change the input type to text.
if your database demands an integer, then you'll have to convert the text string to an integer in your controller. The problem here (i'm pretty sure) is that the zero will be eliminated when it is saved to the database.
hope this helps.
Warning: untested code

Validating input size and value into an "EditTextCell" GWT Datagrid

I have a DataGrid with two editable columns (EdiTextCell). I was wondering if i could control the input value in the first one : Value can only be "R" or "". In the second column (EditTextCell also) the value (String) length must be < 2.
I didn't find an issue to control the value every time it changes to prevent input and clear cell content if not "R" or "" in the first case. in the second case i should stop input if 2 chars.
Any help please?
thank you
You can see an example by searching Google for CellTableFieldUpdaterExampleComplex. Basically, in the FieldUpdater associated with the column you just need to do the following:
cell.clearViewData(KEY_PROVIDER.getKey(object));
cellTable.redraw();

How to change array index to start from 1?

How can I change my array's indices to start from 1 instead of 0. I am trying to fetch news from a site (JSON) and after parsing it:
#news = JSON.parse(Net::HTTP.get(URI.parse('http://api.site.com/news?format=json')))
But to see the individual news title, I have to do #news["items"][0] for the first link's title. Is it possible to change that behavior so when I do #news["items"][1] it shows me the first link's title?
You should intercept user input and adjust entered value to map to a correct array element. In general, you should always validate user input and check if it makes sense.

Telerik MVC CurrencyTextBox - Custom value formatting

(First off, I have already posted this on the Telerik forums (link), but this site gets more traffic, so I'm hoping to get some help sooner.)
I am trying to achieve some custom value formatting with the CurrencyTextBox, but the way that the control handles values is making things decidedly hard.
What I want to do is this: if the user enters a value that does not contain a "." character, it will format that value as cents instead of dollars. So if a user enters "16", I want the control to display (and contain a value of) $0.16. If the user enters a value with a ".", I would like the control to function as normal. If the user enters "16.", "16.0" or "16.00", I want the control to display (and contain a value of) "$16.00". This application will be used by people in the retail business and this is how they expect inputs for price values to function.
However, whether I subscribe to the OnChange event or even the "blur" event on the textbox itself, it is stripping the "." character if there is either nothing after it or only 0's after it. Example: If I enter in a value of "16.", "16.0" or "16.00", the value pulled from the textbox in javascript will be "16". And since I have to check for the presence of the "." character, this breaks my logic to properly format the value.
So I'm looking for some help or suggestions. Here is the javascript that I have right now to properly format the value as required. As you can see, if the value does not contain a "." character, the value is divided by 100, which is exactly what I want. Stripping this character is killing my logic. :)
$('custom-price').find('input').live('blur', function (e) {
var sender = $(this).data('tTextBox');
var priceVal = $(this).val(); // $(this).attr('value') also returns the value with the character stripped, FYI
if (priceVal.indexOf(".") == -1) {
priceVal = priceVal / 100;
}
sender.value(priceVal);
});
Try the same using ascii code for "." operator (46). OnKeyPress if you find ascii code 46 change the format for control..
Regards,
Dhaval Shukla

Jquery Validation test for a value

I want to use jquery validation to validate an user input. He has to insert his Steam Id (a thing of a online game) in a form and I want to validate it but I have no ideia how to do that.
The Steam id expression has to like this: STEAM_0:1:2131341411
The thing that is required is this: STEAM_0:
Then it is just numbers
STEAM:0:(number 1 or 0):(numbers)
Maximum of characters of 20.
I've tried to do a regex thing to put in the add.method function but I couldnt,
Thank you, I hope you've understood what I meant
Try this regular expression: /^STEAM_0:(0|1):[1-9]{1}[0-9]{0,19}$/

Resources