I am new to PHP
All I want to do is Mask Input the phone number
somehow it wouldn't allow Javascript or Jquery
$_SESSION["oh"]["phone"]=(empty($_SESSION["oh"]["phone"]))?$_COOKIE["phone"]:$_SESSION["oh"]["phone"];
Follow kind of patterns to mask the phone and to validate it
$pattern = "/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i"
Reference
AFAIK , we have used the mask() from jquery it helps to validate it
$("#phone").mask("(999) 999-9999");
Its handy to use it
Related
I'm a DNN beginner. I am currently building a module in which I can display statistics. My DotNetNuke Version is 7.0. The statistic is from Chartjs. For this statistic I would like to implement filters. These filters should be datepickers. As UI element I have now included a textbox with TextMode='Date'. But currently I have problems to set the default value of this field. The default value should be 01.01. of the current year.
I have already tried to set the value via C# server side. Unfortunately without success. I also tried to set the value on the client side via JavaScript. Unfortunately also without success.
These are some lines I tried in JavaScript:
document.getElementById(<%= this.DatumVon.AccessKey %>).value = "01.01.2019";
document.getElementById(<%= this.DatumVon.AccessKey %>).innerText = "01.01.2019";
document.getElementById("DatumVon").value = "01.01.2019";
These are some lines I tried in C# in the method "Page_Load" (server side):
this.DatumVon.Text = "01.01.2019";
I expected the value of the TextBox to be 01.01.2019. However, it currently only contains dd.mmm.yyyy. How can I change this?
Thank you.
There is something wrong with your localization. Please refer to the jQuery UI datepicker documentation (the "Localization" section), this should give you the answer.
wow... I solved it. I made it. Sometimes the solution is right in front of you and you don't see it. Michael Tobisch was absolutely right. When setting the value, the format is very important. I have always used the German format. A DNN TextBox with TextMode="Date" can't handle that. DNN converts this TextBox into an HTML input field. But this input field can only be clear with the format "yyyy-mm-dd". Depending on the geographical position of the client (at least that's what I think) the text displayed in the input field will be formatted. But the value of the input field always has the same format ("yyyy-mm-dd"). So very important here: the displayed text and the actual value have different formats.
Many thanks again to Michael Tobisch for the mental inspiration and the patience with me.
What is also important is that the access to the actual ID of a DNN element works as follows: this.Element.ClientID and not as I assumed before this.Element.AccessKey. This was also buggy.
How can we validate a custom field while checkin in to Oracle WebCenter Content?It may be an email validation or custom validation say the file will allow user to input only 10 chars of which first four are alpha and the next sixth char are numeric.
Regards,
Ananda Roy
Try adding a rule to the profile (or using global rule). Then, in the rule side effect, set this: <$xCustomField:maxLength=10$>
You can get fancier validation by doing more customization such as this.
I would like to know how I can filter to detect numbers (integers) only? e.g 1,2,....,10. Currently the api detects all formats of "text".
You should do that processing on your side. Use Regex to filter out numbers from string received from Vision API:
str="Text received 123,0";
number = str.replace(/\D/g,'');
result: 123
Google vision API will detect all character, google vision does not
have separate API(which can detect only number at the point of
scanning) for only numbers till now, But after scanning the image
using google vision api we will get the text in response example
"23XA3783", so now we can replace the character we don't want.
Store the google api response in temp variable
source_str = "23XA3783"
In my case I get the required string from google api response using
js
source_str= temp["responses"][0].textAnnotations[0].description
final_output = source_str.replace(/\D/g,'');
How do I make a text field accept only numeric values? If I press a letter or a symbol, the text field should not be filled, it should only allow numbers.
Is there a rails way to do this?
Use number_field_tag, this will generate a HTML5 number field
http://apidock.com/rails/ActionView/Helpers/FormTagHelper/number_field_tag
On the server side validate numericality:
class SomeModel
validates :some_column, :numericality => {:only_integer => true}
end
and on the client side, add an input mask via javascript https://github.com/ruoso/jquery-regex-mask-plugin
$('#some_input').regexMask(/^\d+$/);
#clyfe's answer is good, but that plugin doesn't work with HTML5 type=number elements. Here's some quick jQuery code that only allows integers:
$("input[type=number]").keypress(function(event) {
if (!event.charCode) return true;
ch = String.fromCharCode(event.charCode);
return (/[\d]/.test(ch));
});
to allow decimals or commas, make the regex look more like those in the plugin, e.g. https://github.com/ruoso/jquery-regex-mask-plugin/blob/master/regex-mask-plugin.js#L8 :
/^((\d{1,3}(\,\d{3})*(((\,\d{0,2}))|((\.\d*)?)))|(\d+(\.\d*)?))$/
(Note that different locales have different conventions for decimals and commas, so it's probably safer to just allow digits :-)
Note also that this is a workaround for the Chrome bugs mentioned here:
https://code.google.com/p/chromium/issues/detail?id=304455
https://github.com/angular/angular.js/issues/2144
I have a model called Client which runs a custom phone number validator to see if a given phone number is valid (validates :phone_number, :run_custom_validator => true). The problem is that this phone number field should not be required, its optional, but the validator runs every time even when no phone number is given. How do I get the validator to run only when a phone number is given? Any responses would be much appreciated! Thanks!
In the custom phone number validator, on the first line put the following:
return if phone_number.blank?