validate

How to validate a checkbox input using PHP?

匿名 (未验证) 提交于 2019-12-03 01:26:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have two check boxes in my form: <div class="label-input-wrapper pickup"> <div class="form-label">I need Airport pick-up</div> <div class="form-input"> <input type="checkbox" name="pick_up" value="Yes" />Yes <input type="checkbox" name="pick_up" value="No" />No <div class="error-msg"> <?php if(isset($errors['pick_up_no'])) { echo '<span style="color: red">'.$errors['pick_up_no'].'</span>'; } ?> </div> </div> </div> Variable that saves the value of the above check boxes: $pickup = $_POST['pick_up']; Validation: //Check the airport pickup

How can I validate dates in Perl?

匿名 (未验证) 提交于 2019-12-03 01:22:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How can I validate date strings in Perl? I'd like to account for leap years and also time zones. Someone may enter dates in the following formats: 11/17/2008 11/17/2008 3pm 11/17/2008 12:01am 11/17/2008 12:01am EST 11/17/2008 12:01am CST 回答1: I use DateTime::Format::DateManip for things like this. Using your dates.... use DateTime::Format::DateManip; my @dates = ( '11/17/2008', '11/17/2008 3pm', '11/17/2008 12:01am', '11/17/2008 12:01am EST', '11/17/2008 12:01am CST', ); for my $date ( @dates ) { my $dt = DateTime::Format::DateManip->parse

How to validate a decimal value input?

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Currently working on only decimal values where in the text field user enter only deciaml value. Should accept only 10 numbers for example if user enter 12345.000000 it should get an alert says Number field format error. Please re-enter using the proper format. (6.3) With my current jquery code it will accept decimal value $ ( "#txtQty" ). keyup ( function () { var $this = $ ( this ); $this . val ( $this . val (). replace ( /[^\d.]/ g , '' )); }); This is my html code for the text box with this html it will allow only 10 character

jQuery Validate Plugin - Trigger validation of single field

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've got a form that can optionally be pre-populated via facebook connect. Once a user connects, their name and email are automatically filled in. The problem is that this doesn't trigger the remote validation to check if the email already exists. Is there a way I could call the validation on that field alone? Something like: $('#email-field-only').validate() would be idea. Searched through the docs with no luck. 回答1: This method seems to do what you want: $('#email-field-only').valid(); 回答2: For some reason, some of the other methods don't

Using regular expressions to validate a numeric range

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My input number is an int. But the input number must be in a range from -2055 to 2055 and I want to check this by using regular expression. So is there anyway to write a regular expression to check whether a number is in (-2055, 2055) or not ? It is easier to use if statement to check whether the number is in range or not. But I'm writing an interpreter so I should use regex to check the input number 回答1: Using regular expressions to validate a numeric range To be clear: When a simple if statement will suffice if(num 2055) { throw new

jQuery Validate: Validate that one field, or both fields of a pair are required

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a form that I am trying to validate that has two fields: Email address: Mobile number: Here's my jQuery Validation wireup: What I'd like to do is add an additional validation rule that says: the form is not valid if both fieldEmailAddress and fieldMobileNumber are blank. In other words, I'd like to make it such that at least one of either fieldEmailAddress or fieldMobileNumber is required. It seems like most of the jQuery Validation custom methods are designed to only work for one field at a time - I need to validate both. Any ideas?

jQuery validate plugin : custom rules with dynamic element id

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have attempted to apply a custom validation rule using jQuery as below <script type="text/javascript"> $(document).ready(function(){ jQuery.validator.addMethod("notaccept", function(value, element, param) { return value.match(new RegExp("." + param + "$")); }, "<img src='../template/images/error.gif' alt='Only alphabet allowed.'>"); $("#frm1").validate({ rules: { $('input[id^=txt_field]'): { notaccept: "[a-zA-Z]+" } } }); }); </script> The issue is the usage of element prefix selector in the above code doesn't work. I generate multiple

ASP.NET: Unable to validate data

匿名 (未验证) 提交于 2019-12-03 01:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the cause of this exception in ASP.NET? Obviously it is a viewstate exception, but I can't reproduce the error on the page that is throwing the exception (a simple two TextBox form with a button and navigation links). FWIW, I'm not running a web farm. Exception Error Message: Unable to validate data. Error Source: System.Web Error Target Site: Byte[] GetDecodedData(Byte[], Byte[], Int32, Int32, Int32 ByRef) Post Data VIEWSTATE: /wEPDwULLTE4NTUyODcyMTFkZF96FHxDUAHIY3NOAMRJYZ+CKsnB EVENTVALIDATION: /wEWBAK

validate that an email address contains “@” and “.”

匿名 (未验证) 提交于 2019-12-03 01:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i need to validate that an inserted email address contains "@" and "." without a regular expression. Can somebody to give me "java code" and "structure chart" examples please? 回答1: I suspect you're after something like: if (!address.contains("@") || !address.contains(".")) { // Handle bad address } EDIT: This is far from a complete validation, of course. It's barely even the start of validation - but hopefully this will get you going with the particular case you wanted to handle. 回答2: You can use commons-validator , Specifically

Validate JavaFX form only after submission using ValidationSupport

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to validate a javafx form using ValidationSupport, the validation is working, but when I access the form the "errors decorations" are already shown, even before the form is submitted or the textfield is focused. ValidationSupport validationSupport = new ValidationSupport(); validationSupport.registerValidator(textField, Validator.createEmptyValidator("Text is required")); The following image shows an example of the form in its initial state. How can I force the decoration to show only after the user submit the form or change the