Search Results

Search found 595 results on 24 pages for 'validating'.

Page 3/24 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Get paperclip to crop the image without validating

    - by Micke
    Hello fellow stackoverflow members. I have been following this guide to enable users to have their own avatar. But i have bumped in to a litle problem. When the user is cropping the image the model tries to validate all my validations. My user model looks like this: class User < ActiveRecord::Base has_attached_file :avatar, :styles => { :small => "100x100>", :large => "500x500>" }, :processors => [:cropper] attr_accessor :password, :crop_x, :crop_y, :crop_w, :crop_h attr_accessible :crop_x, :crop_y, :crop_w, :crop_h validates_confirmation_of :password validates_presence_of :password And when the user runs the crop updating script the user model tries to validate the password. But because i have no password field on the cropping page it can't validate it. Here is the updating of the crop: @user = User.find(current_user.id) if @user.update_attributes(params[:user]) flash[:notice] = "Successfully updated user." end How can i bypass this in a easy and clean way?

    Read the article

  • jquery validate - validating a field on pageload

    - by boz
    Hi there, I've got an input field on my plain html form that I would like to be marked as invalid (and the error message shown) from the moment the page loads. Is this possible to do with the jquery validate plugin? Failing that, how can I hide an element when the plugin tries to validate a particular input field?

    Read the article

  • Validating DataAnnotations with Validator class

    - by Pablote
    I'm trying to validate a class decorated with dataannotation with the Validator class. It works fine when the attributes are applied to the same class. But when I try to use a metadata class it doesn't work. Is there anything I should do with the Validator so it uses the metadata class? Here's some code.. this works: public class Persona { [Required(AllowEmptyStrings = false, ErrorMessage = "El nombre es obligatorio")] public string Nombre { get; set; } [Range(0, int.MaxValue, ErrorMessage="La edad no puede ser negativa")] public int Edad { get; set; } } this doesnt work: [MetadataType(typeof(Persona_Validation))] public class Persona { public string Nombre { get; set; } public int Edad { get; set; } } public class Persona_Validation { [Required(AllowEmptyStrings = false, ErrorMessage = "El nombre es obligatorio")] public string Nombre { get; set; } [Range(0, int.MaxValue, ErrorMessage = "La edad no puede ser negativa")] public int Edad { get; set; } } this is how I validate the instances: ValidationContext context = new ValidationContext(p, null, null); List<ValidationResult> results = new List<ValidationResult>(); bool valid = Validator.TryValidateObject(p, context, results, true); thanks.

    Read the article

  • jQuery Validation Plugin: Validating Checkboxes with Different Names

    - by Michael
    I have a set of 4 checkboxes, all with different names, and require that at least 1 is checked. I know there are a few posts on here already trying to answer this question. The solution that seems to be most logical to me is the answer posted on Question 1734840, but I can't seem to get it working! What's wrong with my code? Or any other new coding ideas to get this working? I have set the class on all of them to 'require-one'. My jQuery code is $(document).ready(function(){ $("#itemForm").validate({ highlight: function(element, errorClass, validClass) { $(element).addClass(errorClass).removeClass(validClass); $(element.form).find("label[for=" + element.name + "]") .addClass("radioerror"); }, unhighlight: function(element, errorClass, validClass) { $(element).removeClass(errorClass).addClass(validClass); $(element.form).find("label[for=" + element.name + "]") .removeClass("radioerror"); }, rules: { 'require-one': { required : { depends: function(element) { var allBoxes = $('.require-one'); if (allBoxes.filter(':checked').length == 0) { if (allBoxes.eq(element).length != 0) { return true; } } return false; } } } , }, errorPlacement: function(error, element) { if ( element.is("#other_descrip") ) error.appendTo("#othererror" ); if ( element.is("#itemlist") ) error.appendTo("#itemerror" ); } }); });

    Read the article

  • validating wsdl/schema using cxf

    - by SGB
    I am having a hard time getting cxf to validate an xml request that my service creates for a 3rd party. My project uses maven. Here is my project structure Main Module : + Sub-Module1 = Application + sub-Module2 = Interfaces In Interfaces, inside src/main/resources I have my wsdl and xsd. so, src/main/resources + mywsdl.wsdl. + myschema.xsd The interface submodule is listed as a dependency in the Application-sub-module. inside Application sub-module, there is a cxsf file in src/maim/resources. <jaxws:client name="{myTargerNameSpaceName}port" createdFromAPI="true"> <jaxws:properties> <entry key="schema-validation-enabled" value="true" /> </jaxws:properties> </jaxws:client> AND:. <jaxws:endpoint name="{myTargetNameSpaceName}port" wsdlLocation="/mywsdl.wsdl" createdFromAPI="true"> <jaxws:properties> <entry key="schema-validation-enabled" value="true" /> </jaxws:properties> </jaxws:endpoint> I tried changing the "name="{myTargetNameSpaceName}port" to "name="{myEndPointName}port" But to no anvil. My application works. But it just do not validate the xml I am producing that has to be consumed by a 3rd party application. I would like to get the validation working, so that any request that I send would be a valid one. Any suggestions?

    Read the article

  • MSBuild Validating Properties

    - by Brian Gillespie
    I'm working on a reusable MSBuild Target that will be consumed by several other tasks. This target requires that several properties be defined. What's the best way to validate that properties are defined, throwing an Error if the are not? Two attempts that I almost like: <?xml version="1.0" encoding="utf-8" ?> <Project ToolsVersion="3.5" DefaultTarget="Release" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="Release"> <Error Text="Property PropA required" Condition="'$(PropA)' == ''"/> <Error Text="Property PropB required" Condition="'$(PropB)' == ''"/> <!-- The body of the task --> </Target> </Project> Here's an attempt at batching. It's ugly because of the extra "Name" parameter. Is it possible to use the Include attribute instead? <?xml version="1.0" encoding="utf-8" ?> <Project ToolsVersion="3.5" DefaultTarget="Release" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Target Name="Release"> <!-- MSBuild BuildInParallel="true" Projects="@(ProjectsToBuild)"/ --> <ItemGroup> <RequiredProperty Include="PropA"><Name>PropA</Name></RequiredProperty> <RequiredProperty Include="PropB"><Name>PropB</Name></RequiredProperty> <RequiredProperty Include="PropC"><Name>PropC</Name></RequiredProperty> </ItemGroup> <Error Text="Property %(RequiredProperty.Name) required" Condition="'$(%(RequiredProperty.Name))' == ''" /> </Target> </Project>

    Read the article

  • Validating a class using DataAnotations

    - by runxc1 Bret Ferrier
    I have a class that I am using to model my data in MVC. I have added some DataAnotations to mark fields that are required and I am using regular expressions to check valid Email Addresses. Everything works fine if the object is posted back to MVC and I have the ModelState property that I can check to confirm that the class is valid but how do I check to see if the class is valid outside of MVC using the same class and Data Anotations that I have already set up?

    Read the article

  • Avoid XmlDocument validating namespaces in C#

    - by Abbey Kingston
    Hello, I'm trying to find a way of indenting a HTML file, I've been using XMLDocument and just using a XmlTextWriter. However I am unable to format it correctly for HTML documents because it checks the doctype and tries to download it. Is there a "dumb" indenting mechanism that doesnt validate or check the document and does a best effort indentation? The files are 4-10Mb in size and they are autogenerated, we have to handle it internal - its fine, the user can wait, I just want to avoid forking to a new process etc. Essentially, right now I use a MemoryStream, XmlTextWriter and XmlDocument, once indented I read it back from the MemoryStream and return it as a string. Failures happen for XHTML documents and some HTML 4 documents because its trying to grab the dtds. I tried setting XmlResolver as null but to no avail :(

    Read the article

  • Validating String Characters as Numeric w/ Pascal (FastReport 4)

    - by user2525015
    I'm new to Pascal and FastReport. This question can probably be answered without knowledge of FastReport. Pascal is Delphi. FastReport4. I have a text box accepting an 8 character string as input. Each character should be numeric. I'm attempting to validate each character as numeric. I've tried using the val function... Procedure Val(S : String; var R: Real; Code : Integer); begin end; procedure thisinputOnChange(Sender: TfrxComponent); var S : String; error : Integer; R : Real; begin S := thisinput.lines.text; Val (S, R, error); If error > 0 then Button2.enabled := False; end; I got this code online. The explanation says that the function will return an error with a code greater than zero if the character cannot be converted to an integer. Is that explanation correct? Am I misinterpreting? Right now I am trying to set a button's enabled property to false if the validation fails. I might change that to a message. For now, I would like to get it to work by setting the button property. I'm not sure if I should be using the onChange event or another event. I'm also not sure if I need to send the input to the val function in a loop. Like I said, I'm just learning how to use this function. I am able to validate the length. This code works... procedure thisinputOnChange(Sender: TfrxComponent); begin if length(thisinput.lines.text) = 8 then Button2.enabled := True; end; Any suggestions? Should I use the val function or something else? Let me know if I need to provide more info. I might not be able to check back until later, though. Thanks for any help.

    Read the article

  • Validating XML using XSD with regex pattern

    - by Steel Plume
    Hello, I am parsing a XML file against a XSD containing some regex patterns used for checking input data, but only this regex generates an error, even if it passes into the Eclipse XSD plugin: InvalidRegex: Pattern value '(((com|it|org)\.)+(\b[a-z]+[.]{1}\b)+)?[A-Z]{1}[A-Za-z]+' is not a valid regular expression. The reported error was: 'This expression is not supported in the current option setting.'. So, with SAX validator where can I find the fatal "current option setting"?

    Read the article

  • Validating Application Settings Key Values in Isolated Storage for Windows Phone Applications

    - by Martin Anderson
    Hello everyone. I am very new at all this c# Windows Phone programming, so this is most probably a dumb question, but I need to know anywho... IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings; if (!appSettings.Contains("isFirstRun")) { firstrunCheckBox.Opacity = 0.5; MessageBox.Show("isFirstRun not found - creating as true"); appSettings.Add("isFirstRun", "true"); appSettings.Save(); firstrunCheckBox.Opacity = 1; firstrunCheckBox.IsChecked = true; } else { if (appSettings["isFirstRun"] == "true") { firstrunCheckBox.Opacity = 1; firstrunCheckBox.IsChecked = true; } else if (appSettings["isFirstRun"] == "false") { firstrunCheckBox.Opacity = 1; firstrunCheckBox.IsChecked = false; } else { firstrunCheckBox.Opacity = 0.5; } } I am trying to firstly check if there is a specific key in my Application Settings Isolated Storage, and then wish to make a CheckBox appear checked or unchecked depending on if the value for that key is "true" or "false". Also I am defaulting the opacity of the checkbox to 0.5 opacity when no action is taken upon it. With the code I have, I get the warnings Possible unintended reference comparison; to get a value comparison, cast the left hand side to type 'string' Can someone tell me what I am doing wrong. I have explored storing data in an Isolated Storage txt file, and that worked, I am now trying Application Settings, and will finally try to download and store an xml file, as well as create and store user settings into an xml file. I want to try understand all the options open to me, and use which ever runs better and quicker

    Read the article

  • Validating User Input? C#

    - by Alex
    Hi, in an assignment, I have designed a input validation loop in C#, and I would like it to be able to check for the correct input format. I'm not for sure, but I think my designed loop is not checking the type of input, just what char is entered. I know I could use a try-catch block, but shouldn't you only use exceptions for exceptional situations? This is not an exceptional situation, because I expect that the user would enter an incorrect value. Input validation is not part of my assignment, so the loop is in a homework assignment, but is not part of the homework assignment. Question: Is there a way I could redesign this loop so that it checks for valid input type as well? Code: do { Console.Write("Do you wish to enter another complex number?: (Y or N)"); response = char.Parse(Console.ReadLine()); response = char.ToUpper(response); if (response != 'Y' && response != 'N') Console.WriteLine("You must respond Y or N!"); } while (response != 'Y' && response != 'N'); Thanks!!

    Read the article

  • Validating button click event using JS from inside ascx nested inside updatepanel

    - by Viswa
    Hello I have a button inside an ascx inside an update panel inside aspx content page. When the button is clicked i want it to run a JS function that causes to show a panel. Here is my Code. <pre> <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ABC.ascx.cs" Inherits="App.ABC" %> <script type= "text/javascript" language="javascript"> var val1=0; var val2=0; function ShowPanel(val2) { if(val2 != 0) { switch(val2) { case 1 : document.getElementById('<%=pnl1.ClientID%>').style.visibility = 'visible'; break; } } return false; } </script> <asp:LinkButton ID="lbl1" runat="server" OnClick="return ShowPanel(1);">count</asp:LinkButton> I am not sue how to do this. Please help Update #1 - ABC.ascx is in updatepanel in the aspx page XYZ.aspx <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ABC.ascx.cs" Inherits="App.ABC" %> <script type= "text/javascript" language="javascript"> var val1=0; var val2=0; function ShowPanel(val2) { if (val2 != 0) { switch (val2) { case 1: document.getElementById("<%= this.pnl1.ClientID%>").style.display = "none"; break; } } return false; } </script> <div> <div style="text-align:center"> </div> <table style="width:100%; text-align:center; border-color:#99CCFF" border="3"> <tr style="text-align:left"> <td><asp:LinkButton ID="lbl1" runat="server" OnClientClick="return ShowPanel(1);">count</asp:LinkButton> </td> <td style="text-align:right"><asp:Button ID="btnHide1" runat="server" Text="hide" Height="18px" Width="32px"/> </td> </tr> <tr> <td colspan="2"><asp:Panel ID="pnl1" runat="server" Visible="false"> </asp:Panel> </td> </tr> </table> </div>

    Read the article

  • Validating only selected fields using ASP.NET MVC 2 and Data Annotations

    - by thinknow
    I'm using Data Annotations with ASP.NET MVC 2 as demonstrated in this post: http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx Everything works fine when creating / updating an entity where all required property values are specified in the form and valid. However, what if I only want to update some of the fields? For example, let's say I have an Account entity with 20 fields, but I only want to update Username and Password? ModelState.IsValid validates against all the properties, regardless of whether they are referenced in the submitted form. How can I get it to validate only the fields that are referenced in the form?

    Read the article

  • Validating a wrong date entry in rich faces

    - by Hiral Lakdavala
    Hi, (On behalf of a collegue) In one of our functionality we have some date fields for inline edit where we have enabled manual input. If in rich:calendar component, we manually enter improper date or junk data it will not even call the action method. As per our requirement we need to display an error message for date validation for these kind of fields. Is there any way to track that the date entered in the calendar field is improper with this component. Code for the reference: <rich:calendar id="actualOpeningDtCal" rendered="#{!empty storeProgram.id}" value="#{storeProgram.actualOpeningDate}" placeholder="dd-mmm-yyyy" inputSize="20" enableManualInput="true" datePattern="dd-MMM-yyyy" buttonIcon="../content/images/calendar.png" showWeeksBar="false" showFooter="false"> <a4j:support event="oninputblur" reRender="aList" ajaxSingle="false" action="#{aController.inlineEdit}"> <f:setPropertyActionListener value="#{aProgram}" target="#{aController.inLineEditaBean}" /> </a4j:support> <a4j:support event="oncollapse" reRender="aList" ajaxSingle="false" action="#{aController.inlineEdit}"> <f:setPropertyActionListener value="#{aProgram}" target="#{aController.inLineEditaBean}" /> </a4j:support> </rich:calendar> Regards, Hiral

    Read the article

  • validating creation by post_id and ip_address - Ruby on Rails

    - by bgadoci
    I have created a blog application using Ruby on Rails which includes the ability to vote on posts. A user can click vote and a record is created in the vote table. I am now trying to limit that same person from voting for a post multiple times. class Post has_many :votes end class Vote belongs_to :post end When a vote record is created I am using the VotesController to pass the :post_id and using a hidden field in the view to pass the ip_address (both to the vote table). I am wondering if there is a way to add a validation to the Vote Model that searches to see if a post_id has an ip_address that matches the person requesting to vote. I have tried simply using the validates_uniqueness_of :ip_address but that restricts the user from voting on any post. I just want to restrict the user from voting on a particular post that they have already voted on. Is there a way to do this through validation?

    Read the article

  • C# - Regular Expression validating Date and Hour

    - by nettguy
    I receive Date and time from CSV file The received Date format is YYYMMDD (string) (there is no ":" ,"-","/" to separate Year month and date). The received time format is HH:MM (24 Hour clock). I have to validate both so that (example) (i) 000011990 could be invalidated for date (ii) 77:90 could be invalidated for time. The question is , Regular expression is the right candidate for do so (or) is there any other way to achieve it?

    Read the article

  • Validating method arguments with Data Annotation attributes

    - by schemer
    The "Silverlight Business Application" template bundled with VS2010 / Silverlight 4 uses DataAnnotations on method arguments in its domain service class, which are invoked automagically: public CreateUserStatus CreateUser(RegistrationData user, [Required(ErrorMessageResourceName = "ValidationErrorRequiredField", ErrorMessageResourceType = typeof(ValidationErrorResources))] [RegularExpression("^.*[^a-zA-Z0-9].*$", ErrorMessageResourceName = "ValidationErrorBadPasswordStrength", ErrorMessageResourceType = typeof(ValidationErrorResources))] [StringLength(50, MinimumLength = 7, ErrorMessageResourceName = "ValidationErrorBadPasswordLength", ErrorMessageResourceType = typeof(ValidationErrorResources))] string password) { /* do something */ } If I need to implement this in my POCO class methods, how do I get the framework to invoke the validations OR how do I invoke the validation on all the arguments imperatively (using Validator or otherwise?).

    Read the article

  • XHTML validating block level element as a link

    - by Matty F
    I need a way to make an entire DL element clickable with only one anchor tag, that validates as XHTML. As in: <a> <dl> <dt>Data term</dt> <dd>Data definition</dd> </dl> </a> This currently doesn't validate as XHTML as the anchor tag cannot contain the DL. The only way I can get it to validate is if I make two anchor tags and place them inside DT and DD. As in: <dl> <dt><a>Data term</a></dt> <dd><a>Data definition</a></dt> </dl> I'm trying to avoid this, as it would result in two href attributes requiring maintenance, introducing the possibility they could become out of sync. Suggestions?

    Read the article

  • Validating disconnected POCOs

    - by jonathanconway
    In my ASP.NET application I have separate projects for the Data, Business and UI layers. My business layer is composed of plain objects with declarative validation, using DataAnnotations. Problem is, when it comes to save them, I'm not sure how to process the validation, since they're not bound directly to any data context, but rather, are mapped to separate data-layer objects. Is there a way to trigger validation on these kinds of objects?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >