validate

How to Validate FormArray length in angular2

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a data driven form in angular2 like below this.formBuilder.group({ 'name': ['',Validators.required], 'description': ['', Validators.required], 'places': this.formBuilder.array([], Validators.minlength(1)) }) I want to add validations to the place formArray, so i am adding minlength validation, but minlength validation is not working on formArray. What are the other validations for formArray, so that form must be valid only when places array contain atleast one place. 回答1: Add this custom validator to your validation service:

jQuery validate only if a specific radio button is selected

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I got stuck at a particular situation I have 2 radio buttons <input type="radio" value="YES" id="sub" name="sub">Yes <input type="radio" value="NO" id="sub" name="sub">No When, Yes is selected, I need to validated 1 text-field <input type="text" id="price" name="price" /> I am using jQuery validation plug-in Please help me with this, Thanks. 回答1: You can set up dependency validation as seen here http://docs.jquery.com/Plugins/Validation/Methods/required#dependency-expression $('#myForm').validate(rules: { price: { required: '#sub[value="YES"

How to validate a SAML signature value

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a customer who is sending a Security key. The encryption they are using is triple DES. Every Assertion they send has a signature value which needs to be validated to give them necessary privileges. Can you give me a sample code which does this? 回答1: Encryption and signing are two different animals. Triple DES is a symmetric key method (same key used for encryption and decryption). Digital signatures, on the other hand, use asymmetric keys (private/public key pair), where the signature is computed using the private key, and

Trying to Validate URL Using JavaScript

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to validate a URL and display message. Below is my code: $("#pageUrl").keydown(function(){ $(".status").show(); var url = $("#pageUrl").val(); if(isValidURL(url)){ $.ajax({ type: "POST", url: "demo.php", data: "pageUrl="+ url, success: function(msg){ if(msg == 1 ){ $(".status").html(' SiteID: 12345678901234456 '); }else{ $(".status").html(' '); } } }); }else{ $(".status").html(' '); } }); function isValidURL(url){ var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; if(RegExp.test(url)){

validate natural input number with ngpattern

匿名 (未验证) 提交于 2019-12-03 02:43:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use ng-pattern="/0-9/" to set price_field do not accept decimal number . But when I input natural number (from 0 to 9999999), ng-show gets activated with Not valid number! . Where did I go wrong?. Please help. Not valid number! 回答1: The problem is that your REGX pattern will only match the input "0-9". To meet your requirement (0-9999999), you should rewrite your regx pattern: ng-pattern="/^[0-9]{1,7}$/" My example: HTML: Not a valid number! This field is required! JS: function formCtrl($scope){ $scope.onSubmit = function(){ alert("form

Validate JSON against JSON Schema C#

匿名 (未验证) 提交于 2019-12-03 02:42:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there a way to validate a JSON structure against a JSON schema for that structure? I have looked and found JSON.Net validate but this does not do what I want. JSON.net does: JsonSchema schema = JsonSchema.Parse(@"{ 'type': 'object', 'properties': { 'name': {'type':'string'}, 'hobbies': {'type': 'array'} } }"); JObject person = JObject.Parse(@"{ 'name': 'James', 'hobbies': ['.NET', 'LOLCATS'] }"); bool valid = person.IsValid(schema); // true This validates to true. JsonSchema schema = JsonSchema.Parse(@"{ 'type': 'object', 'properties': {

Validate data using DataAnnotations with WPF &amp; Entity Framework?

匿名 (未验证) 提交于 2019-12-03 02:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there any way to validate using DataAnnotations in WPF & Entity Framework? 回答1: You can use the DataAnnotations.Validator class, as described here: http://johan.driessen.se/archive/2009/11/18/testing-dataannotation-based-validation-in-asp.net-mvc.aspx But if you're using a "buddy" class for the metadata, you need to register that fact before you validate, as described here: http://forums.silverlight.net/forums/p/149264/377212.aspx TypeDescriptor.AddProviderTransparent( new AssociatedMetadataTypeTypeDescriptionProvider(typeof(myEntity),

how to validate numericupdown when value change (and not lost focus)

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a NumericUpDown and I need when value change (and not lostfocus) do a new calculation if i put my code in event ValueChanged this work when focus is lost if i put my code in KeyPress then if number is not enter by keyboard (example copy a number and paste it) it doesn't work then what event do i need use? and if this is keypress i need concatenate the numeric value more the key pressed convert all this to string and convert it to decimal, and do the calculate, but it does not work if key pressed is not a number (example backspace) 回答1

jQuery detect and validate an URL

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Let's imagine I have this text: Hi, my name is Pablo and my home page is http://zad0xsis.net How can I detect and validate the URL so it automatically wraps it into <a href="the detected url">the detected url</a> ? Thanks! 回答1: You could use a regex: var s = 'Hi, my name is Pablo and my home page is http://zad0xsis.net'; var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; s = s.replace(exp,"<a href=\"$1\">$1</a>"); alert(s); Live demo . 回答2: Can also try the jquery linkify plugin @ http://code.google.com

LightOpenID validate() fail on Google Apps

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm using LightOpenID to authenticate OpenID against Google Apps. I make the initial authURL() request and things are good. I call validate() and it fails. Through copious echo's, i've tracked it down to the last few lines of validate(). From validate(), the url passed into discover($url) is https://www.google.com/accounts/o8/user-xrds?uri=http://my-domain.com/openid?id=117665028262121597341 discover() first checks for an xrds-location, which is not present. discover() next checks if the content-type is xrds+xml, which is true.