Search Results

Search found 7702 results on 309 pages for 'django validation'.

Page 58/309 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • How to do server-side validation using Jqgrid?

    - by Eoghan
    Hi, I'm using jqgrid to display a list of sites and I want to do some server side validation when a site is added or edited. (Form editing rather than inline. Validation needs to be server side for various reasons I won't go into.) I thought the best way would be to check the data via an ajax request when the beforeSubmit event is triggered. However this only seems to work when I'm editing an existing row in the grid - the function isn't called when I add a new row. Have I got my beforeSubmit in the wrong place? Thanks for your help. $("#sites-grid").jqGrid({ url:'/json/sites', datatype: "json", mtype: 'GET', colNames:['Code', 'Name', 'Area', 'Cluster', 'Date Live', 'Status', 'Lat', 'Lng'], colModel :[ {name:'code', index:'code', width:80, align:'left', editable:true}, {name:'name', index:'name', width:250, align:'left', editrules:{required:true}, editable:true}, {name:'area', index:'area', width:60, align:'left', editable:true}, {name:'cluster_id', index:'cluster_id', width:80, align:'right', editrules:{required:true, integer:true}, editable:true, edittype:"select", editoptions:{value:"<?php echo $cluster_options; ?>"}}, {name:'estimated_live_date', index:'estimated_live_date', width:120, align:'left', editable:true, editrules:{required:true}, edittype:"select", editoptions:{value:"<?php echo $this->month_options; ?>"}}, {name:'status', index:'status', width:80, align:'left', editable:true, edittype:"select", editoptions:{value:"Live:Live;Plan:Plan;"}}, {name:'lat', index:'lat', width:140, align:'right', editrules:{required:true}, editable:true}, {name:'lng', index:'lng', width:140, align:'right', editrules:{required:true}, editable:true}, ], height: '300', pager: '#pager-sites', rowNum:30, rowList:[10,30,90], sortname: 'cluster_id', sortorder: 'desc', viewrecords: true, multiselect: false, caption: 'Sites', editurl: '/json/sites' }); $("#sites-grid").jqGrid('navGrid','#pager-sites',{edit:true,add:true,del:true, beforeSubmit : function(postdata, formid) { $.ajax({ url : 'json/validate-site/', data : postdata, dataType : 'json', type : 'post', success : function(data) { alert(data.message); return[data.result, data.message]; } }); }});

    Read the article

  • How to solve validation error on xsi:noNamespaceSchemaLocation in jdoconfig.xml

    - by mamuso
    Since I updated today to GAE 1.7.2.1, I'm having validation errors in eclipse in all my jdoconfig.xml files. I have the default jdoconfig.xml content : [...] <jdoconfig xmlns="http://java.sun.com/xml/ns/jdo/jdoconfig" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://java.sun.com/xml/ns/jdo/jdoconfig"> [...] And eclipse validation throws: Referenced file contains errors (http://java.sun.com/xml/ns/jdo/jdoconfig). For more information, right click on the message in the Problems View and select "Show Details..." When clicking on details I can see a bunch of lines like: s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'var_U = "undefined";'. In different lines and different content in "Saw ... " It occurs in every single project I start using the "New Web Application Project..." from the google plugin. So does anyone have this problem? Any fix?

    Read the article

  • ASP.NET MVC 2.0 Validation and ErrorMessages

    - by Raj Aththanayake
    I need to set the ErrorMessage property of the DataAnnotation's validation attribute in MVC 2.0. For example I should be able to pass an ID instead of the actual error message for the Model property, for example... [StringLength(2, ErrorMessage = "EmailContentID")] [DataType(DataType.EmailAddress)] public string Email { get; set; } Then use this ID ("EmailContentID") to retrieve some content(error message) from a another service e.g database. Then the error error message is displayed to the user instead of the ID. In order to do this I need to set the DataAnnotation validation attribute’s ErrorMessage property. It seems like a stright forward task by just overriding the DataAnnotationsModelValidatorProvider‘s protected override IEnumerable GetValidators(ModelMetadata metadata, ControllerContext context, IEnumerable attributes) However it is complicated now.... A. MVC DatannotationsModelValidator’s ErrorMessage property is readonly. So I cannot set anything here B. System.ComponentModel.DataAnnotationErrorMessage property(get and set) which is already set in MVC DatannotationsModelValidator so I cannot set it again. If I try to set it I get “The property cannot set more than once…” error message. public class CustomDataAnnotationProvider : DataAnnotationsModelValidatorProvider { protected override IEnumerable<ModelValidator> GetValidators(ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes) { IEnumerable<ModelValidator> validators = base.GetValidators(metadata, context, attributes); foreach (ValidationAttribute validator in validators.OfType<ValidationAttribute>()) { messageId = validator.ErrorMessage; validator.ErrorMessage = "Error string from DB And" + messageId ; } //...... } } Can anyone please give me the right direction on this? Thanks in advance.

    Read the article

  • jQuery validation plugin and .ajax

    - by FALCONSEYE
    So, I have a form where I load divs as I go asking for various user input and displaying some offers. I have the following: $("#calcPrice").click(function() { $("#invPricing").validate({ rules: { ... }, messages: {... } , submitHandler: function(form) { .... $.ajax({ }); $.ajax({ }); return false; } }); My problem is after validation, none of the ajax calls work. If I remove the validation methods (rules, messages, submitHandler), everything works fine. Can somebody tell me what I am missing here? thanks in advance. btw, these are the ajax calls: $.ajax({ dataType: "json", type: "get", url: <cfoutput>"#actURL#"</cfoutput>, data: formData+"&p_type=LOW&returnJSON=true", cache: false, success: function(result) { // fields to populate: $("#rent").val(result.RENT); $("#discount").val(result.DISCOUNT); $("#salesPrice1").val(result.SALESPRICE); $("#cashPrice1").val(result.CASHSALESPRICE); $("#tax1").val(result.SALESTAX); $("#payment1").val(result.PAYMENTS); } , error: function(xmlHttpRequest, status, err) { confirm('Error!' + err); } }); $.ajax({ dataType: "json", type: "get", url: <cfoutput>"#actURL#"</cfoutput>, data: formData+"&p_type=HIGH&returnJSON=true", cache: false, success: function(result) { // fields to populate: $("#rent").val(result.RENT); $("#discount").val(result.DISCOUNT); $("#salesPrice2").val(result.SALESPRICE); $("#cashPrice2").val(result.CASHSALESPRICE); $("#tax2").val(result.SALESTAX); $("#payment2").val(result.PAYMENTS); } , error: function(xmlHttpRequest, status, err) { confirm('Error!' + err); } }); I am basically displaying two offers one Low, one High.

    Read the article

  • ASP.NET MVC 2 validation LINQ to SQL

    - by Chino
    Currently I have a DataModel object which contains my linq to sql classes(a dmbl file). Currently I use a partial class to validate the incoming input. For example public partial class User : IEntity { public NameValueCollection CheckModel() { return GetRuleViolations(); } /// <summary> /// Method validates incoming data, by given rules in the if statement. /// </summary> /// <returns>NameValueCollection</returns> private NameValueCollection GetRuleViolations() { NameValueCollection errors = new NameValueCollection(); if (string.IsNullOrEmpty(Username)) errors.Add("Username", "A username is required"); // and so on return errors; } } Now what I want to try to do is add validation attributes to the fields. For example I want to try to add the required attribute to the field Username instead/in addtion of using the validation I currently have. My question is how can I achieve this because the dmbl file is auto generated. Or maybe it is not possible and should I use a different approach?

    Read the article

  • C# mvc2 client side form validation with xval, prevent post

    - by Rob
    I'm using xval to use client side validation in my asp.net mvc2 webapplication. Despite the errors it's giving when i enter text in a nummeric field it still tries to post the form to the database. The incorrect values are being replaced by 0 and saved to the database. But instead it shouldn't even be possible to try and submit the form. Can anyone help me out here? I've set the attributes as below; [Property] [ShowColumnInCrud(true, label = "FromPriceInCents")] [Required] //[Range(1, Int32.MaxValue)] public virtual Int32 FromPriceInCents{ get; set; } The controller catching the request looks as below; I'm getting no errors in this part. [AcceptVerbs(HttpVerbs.Post)] [Transaction] [ValidateInput(false)] public override ActionResult Create() { //some foo happens } My view looks like below; <div class="label"><label for="Price">FromPrice</label></div> <div class="field"> <%= Html.TextBox("FromPriceInCents")%> <%= Html.ValidationMessage("product.FromPriceInCents")%></div> And at the end of the view i have the following rule which in html code generates the correct validation rules <%= Html.ClientSideValidation<Product>("Product") %> I hope someone can helps me out with this issue, thanks in advance!

    Read the article

  • WPF Style Override breaks Validation Error event propagation

    - by Ben McMillan
    I have a custom control that overrides Window: public class Window : System.Windows.Window { static Window() { DefaultStyleKeyProperty.OverrideMetadata(typeof(Window), new System.Windows.FrameworkPropertyMetadata(typeof(Window))); } ... } It also has a style: <Style TargetType="{x:Type Controls:Window}" BasedOn="{StaticResource {x:Type Window}}"> <Setter Property="WindowStyle" Value="None" /> <Setter Property="Padding" Value="5" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Controls:Window}"> ... Unfortunately, this breaks the propagation of the Validation.ErrorEvent for my window's contents. That is, my window can receive the event just fine, but I don't know what to do with it to mimic how a standard Window (or whoever) deals with it. If the validating controls are placed in a standard window, they work. They also work if I just take out the OverrideMetadata call (leaving them inside my custom window). Why is this happening, and how can I get the stock functionality for handling these validation error events working again? Thanks!

    Read the article

  • Doctrine unsigned validation error storing created_at

    - by Alex Dean
    Hi, I'm having problems with the Timestampable functionality in Doctrine 1.2.2. The error I get on trying to save() my Record is: Uncaught exception 'Doctrine_Validator_Exception' with message 'Validation failed in class XXX 1 field had validation error: * 1 validator failed on created_at (unsigned) ' in ... I've created the relevant field in the MySQL table as: created_at DATETIME NOT NULL, Then in setTableDefinition() I have: $this->hasColumn('created_at', 'timestamp', null, array( 'type' => 'timestamp', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'notnull' => true, 'autoincrement' => false, )); Which is taken straight from the output of generateModelsFromDb(). And finally my setUp() looks like: public function setUp() { parent::setUp(); $this->actAs('Timestampable', array( 'created' => array( 'name' => 'created_at', 'type' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'disabled' => false, 'options' => array() ), 'updated' => array( 'disabled' => true ))); } (I've tried not defining all of those fields for 'created', but I get the same problem.) I'm a bit stumped as to what I'm doing wrong - for one thing I can't see why Doctrine would be running any unsigned checks against a 'timestamp' datatype... Any help gratefully received! Alex

    Read the article

  • Conditional required field validation in an ASP.net ListView

    - by Jim Dagg
    I'm having a heck of a time trying to figure out how to implement validation in a ListView. The goal is to require the user to enter text in the comments TextBox, but only if the CheckBox is checked. Downside is that these controls are in the EditTemplate of a ListView. Below is a snippet of the relevant code portion of the EditTemplate: <tr style="background-color: #00CCCC; color: #000000"> <td> Assume Risk? <asp:CheckBox ID="chkWaive" runat="server" Checked='<%# Bind("Waive") %>' /> </td> <td colspan="5"> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Comments required" ControlToValidate="txtComments" /> <asp:TextBox Width="95%" ID="txtComments" runat="server" Text='<%# Eval("Comment") %>'></asp:TextBox> </td> <td> <asp:Button ID="btnSave" runat="server" Text="Save" CommandName="Update" Width="100px" /> </td> </tr> Is there a way to do conditional validation using this method? If not, is there a way I could validate manually in the ItemUpdating event of the Listview, or somewhere else, and on a failure, alert the user of the error via a label or popup alert?

    Read the article

  • Is there a PHP library that performs MySQL Data Validation and Sanitization According to Column Type

    - by JW
    Do you know of any open source library or framework that can perform some basic validation and escaping functionality for a MySQL Db. i envisage something along the lines of: //give it something to perform the quote() quoteInto() methods $lib->setSanitizor($MyZend_DBAdaptor); //tell it structure of the table - colnames/coltypes/ etc $lib->setTableDescription($tableDescArray); //use it to validate and escape according to coltype foreach ($prospectiveData as $colName => $rawValue) if ( $lib->isValid($colName, $rawValue)) { //add it to the set clause $setValuesArray[$lib->escapeIdentifier($colName);] = $lib->getEscapedValue($colName,$rawValue); } else { throw new Exception($colName->getErrorMessage()); } etc... I have looked into - Zend_Db_Table (which knows about a table's description), and - Zend_Db_Adaptor (which knows how to escape/sanitize values depending on TYPE) but they do not automatically do any clever stuff during updates/inserts Anyone know of a good PHP library to preform this kind of validation that I could use rather than writing my own? i envisage alot of this kind of stuff: ... elseif (eregi('^INT|^INTEGER',$dataset_element_arr[col_type])) { $datatype='int'; if (eregi('unsigned',$dataset_element_arr[col_type])) { $int_max_val=4294967296; $int_min_val=0; } else { $int_max_val=2147483647; $int_min_val=-2147483648; } } (p.s I know eregi is deprecated - its just an example of laborious code)

    Read the article

  • Xpages conditional validation: make a field required only if report is being submitted as final

    - by Randal Oulton
    Doing server-side Xpages conditional validation.... I want the follow validation to kick in only if the Report.Status field = 'Final'. (The users are allowed to submit the report as draft and come back and finish it later, when they submit as draft we don't want to make the fields required.) How would I go about this? <xp:inputTextarea style="width:75%" value="#{Report.Agenda}" id="Agenda"> <xp:this.validators> <xp:validateRequired message="Question 1 can't be blank"> </xp:validateRequired><!-- (1) --> </xp:this.validators> </xp:inputTextarea> Tried this, didn't work, was still required even if Status field not set to final :{ <xp:inputTextarea style="width:75%" value="#{Report.Agenda}" id="Agenda" defaultValue="5 year agenda"> <xp:this.validators> <xp:validateRequired message="Question 1 can't be blank"></xp:validateRequired><!-- (1) --> <xp:validateExpression message="Question 1 can't be blank"> <xp:this.expression><![CDATA[#{javascript: if (Report.getItemValueString('Status')!='Final') { return true; } else { return false; } }]]></xp:this.expression> </xp:validateExpression> </xp:this.validators> </xp:inputTextarea>

    Read the article

  • Validation not bubbling up to my other models.

    - by DJTripleThreat
    Ok, I have a relationship between People, Users and Employees such that All Employees are Users and all Users are People. Person is an abstract class that User is derived from and Employee is derived from that. Now... I have an EmployeesController class and the create method looks like this: def create @employee = Employee.new(params[:employee]) @employee.user = User.new(params[:user]) @employee.user.person = Person.new(params[:person]) respond_to do |format| if @employee.save flash[:notice] = 'Employee was successfully created.' format.html { redirect_to(@employee) } format.xml { render :xml => @employee, :status => :created, :location => @employee } else format.html { render :action => "new" } format.xml { render :xml => @employee.errors, :status => :unprocessable_entity } end end end As you can see, when I'm using the :polymorphic => true clause, the way you access the super class is by doing something like @derived_class_variable.super_class_variable.super_super_etc. The Person class has a validates_presence_of :first_name and when it is satisfied, on my form, everything is OK. However, if I leave out the first name, it won't prevent the employee from being saved. What happens is that the employee record is saved but the person record isn't (because of the validation). How can I get the validation errors to show up in the flash object?

    Read the article

  • jQuery validation plugin - removing elements

    - by d3020
    I'm using the jQuery validation plugin. On most of my input type... tags I have class='required'. When I submit the page, via JavaScript, the controls on the page that have this class are found. However, there are a handful of checkboxes that I don't need to validate. I've tried removing the class code completely from the input tag, also tried class='cancel', and class='required:false. When doing any of those things though when the form submits it can't find the checkbox control. How do I still keep the ability to do Request.Form and find my checkbox object but at the same time when the form submits don't apply validation to this particular control. Thank you. Edit here. This is what I'm using without the "checked" code and ternary operator. In my input tag I'm calling a function like this... sb.Append(" " + crlf); Inside that function is where I check for the True or False coming back, like this. case "chkFlashedCarton": strResultValue = pst.FlashedCarton.ToString(); if (strResultValue == "True") { strResultValue = " checked"; } break; strResultValue is what is returned back. Does this help to see? Thank you.

    Read the article

  • Error with Property Validation in Form Submission in ASP.NET MVC

    - by Maxim Z.
    I have a simple form on an ASP.NET MVC site that I'm building. This form is submitted, and then I validate that the form fields aren't null, empty, or improperly formatted. However, when I use ModelState.AddModelError() to indicate validation errors from my controller code, I get an error when my view is re-rendered. In Visual Studio, I get that the following line is highlighted as being the location of the error: <%=Html.TextBox("Email")%> The error is the following: NullReferenceException was unhandled by user code - object reference not set to an instance of an object. My complete code for that textbox is the following: <p> <label for="Email">Your Email:</label> <%=Html.TextBox("Email")%> <%=Html.ValidationMessage("Email", "*") %> </p> Here's how I'm doing that validation in my controller: try { System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress(email); } catch { ModelState.AddModelError("Email", "Should not be empty or invalid"); } return View(); Note: this applies to all of my fields, not just my Email field, as long as they are invalid.

    Read the article

  • OnSubmit does work right in the Validation plugin in jQuery

    - by novellino
    Hello, I an quite new to jQuery and I have a problem while trying to create a form. I am using the Validation plugin for validate the email (one the form's field). When I click the Submit button I want to call my own function because I want to save the data in an XML file. This is my button: (as I understood the plugin uses "submit" for understand the button) <input type="submit" name="submit" class="submit" id="submit_btn" value="Send"/> and here is the script for the validation: <script type="text/javascript"> $(document).ready(function() { //this is my form $("#contactForm").validate(); /*save the valid data in the xml*/ $(".submit").click(function() { var email = $("input#email").val(); var subject = $("input#subject").val(); var message = $("textarea#message").val(); if (email == "" || !$("#contactForm").valid()) { return false; } var dataString = 'email='+ email + '&subject=' + subject + '&message=' + message; //alert("DATA: " +dataString); $.ajax({ type: "POST", url: "SaveData.jsp", data: dataString, success: function(data){} }); return false; }); }); In general it works ok but I have two basic problems. When I click the button in the beginning having all the form empty, I get no message for the field required. Also when the data are valid and I am doing the submit, the form does not become clear after the submit. If I deleted this script code, these actions are working properly but I can not save the data! Does anyone know what is wrong? Thanks a lot!

    Read the article

  • Cannot clear the form after Submit using the Validation plugin in jQuery

    - by novellino
    Hello, I an quite new to jQuery and I have a problem while trying to create a form. I am using the Validation plugin for validate the email (one the form's field). When I click the Submit button I want to call my own function because I want to save the data in an XML file. This is my button: (as I understood the plugin uses "submit" for understand the button) <input type="submit" name="submit" class="submit" id="submit_btn" value="Send"/> and here is the script for the validation: <script type="text/javascript"> $(document).ready(function() { //this is my form $("#contactForm").validate(); /*save the valid data in the xml*/ $(".submit").click(function() { var email = $("input#email").val(); var subject = $("input#subject").val(); var message = $("textarea#message").val(); if (email == "" || !$("#contactForm").valid()) { return false; } var dataString = 'email='+ email + '&subject=' + subject + '&message=' + message; //alert("DATA: " +dataString); $.ajax({ type: "POST", url: "SaveData.jsp", data: dataString, success: function(data){} }); return false; }); }); </script> In general it works ok but I have two basic problems. When I click the button in the beginning having all the form empty, I get no message for the field required. Also when the data are valid and I am doing the submit, the form does not become clear after the submit. If I deleted this script code, these actions are working properly but I can not save the data! Does anyone know what is wrong? Thanks a lot!

    Read the article

  • Help with jQuery Validation plugin and a form that uses 'panels'

    - by alex
    I have a form that works in 'sections' that I will refer to as 'panels'. By default, the form is listed out on the page, one panel after the other. However, with JavaScript, it puts the panels into one panel viewer, and displays them one after the other (with prev/next buttons). Example Form Workflow Panel 1: User Details - Panel 2: User Location - Panel 3: User Info - Panel 4: Confirm Details I am using the jQuery Validation plugin. My problem is, I have set up all the rules for all the inputs in the first 3 panels, and I'd like to be able to only validate a subset of them per panel. Example, when pushing 'next panel' after completing name & email (in the 1st, user details panel), I'd like to do a validation only on that panel first, and then get a boolean response (if the 1st panel validated), and if true, then proceed to the next panel. I've played around with a bit of the config, but unfortunately could not get it to work as I wanted. This is my first project with this plugin so I'm quite new to it! Is there a way to add rules dynamically to the plugin? i.e. not on $('form').validate(options) ? What I'd like to do, is call the validate() on the form, with all the error messages, and then on the 'next panel' code, do a switch case to determine which rules to add, and then call a validate() myself.

    Read the article

  • Problem with OnSubmit in Validation plugin in jQuery

    - by novellino
    Hello, I an quite new to jQuery and I have a problem while trying to create a form. I am using the Validation plugin for validate the email (one the form's field). When I click the Submit button I want to call my own function because I want to save the data in an XML file. This is my button: (as I understood the plugin uses "submit" for understand the button) <input type="submit" name="submit" class="submit" id="submit_btn" value="Send"/> and here is the script for the validation: <script type="text/javascript"> $(document).ready(function() { //this is my form $("#contactForm").validate(); /*save the valid data in the xml*/ $(".submit").click(function() { var email = $("input#email").val(); var subject = $("input#subject").val(); var message = $("textarea#message").val(); if (email == "" || !$("#contactForm").valid()) { return false; } var dataString = 'email='+ email + '&subject=' + subject + '&message=' + message; //alert("DATA: " +dataString); $.ajax({ type: "POST", url: "SaveData.jsp", data: dataString, success: function(data){} }); return false; }); }); </script> In general it works ok but I have two basic problems. When I click the button in the beginning having all the form empty, I get no message for the field required. Also when the data are valid and I am doing the submit, the form does not become clear after the submit. If I deleted this script code, these actions are working properly but I can not save the data! Does anyone know what is wrong? Thanks a lot!

    Read the article

  • Inserting an element within jQuery Validation plugin's error template

    - by simshaun
    I'm utilizing the jQuery Validation plugin for my form. It lets you change the errorElement and wrap the errorElement using with the wrapper option. But, I want to insert an element within errorElement like this: <label class="error"><em></em>Error message goes here</label> Is there an easy way to accomplish inserting the em tag? I've tried prepending the em tag using the errorPlacement option (see below), but it seems the plugin is replacing the contents of errorElement afterwards. $.validator.setDefaults({ errorPlacement: function(error, element) { error.prepend('<em/>'); error.insertBefore(element); } }); I've also tried prepending the em tag using the showErrors option (see below). Again, it seems the plugin is replacing the contents of errorElement afterwards. $.validator.setDefaults({ showErrors: function(errorMap, errorList) { for (var i = 0; i < errorList.length; i++) { var error = errorList[i], $label = this.errorsFor(error.element), $element = $(error.element); if ($label.length && $label.find('em').length == 0) { $label.prepend('<em/>'); } } this.defaultShowErrors(); } }); I've also tried modifying the plugin so that when the error element is generated, the <em> tag is prepended. That works until I focus on a form element that has an error, after which the em tag is removed. (It's doing this because jQuery validation is constantly updating the contents of the error element as I focus and/or type in the field, therefore erasing my em tag added at error-element creation.)

    Read the article

  • How use unobtrusive validation without a model

    - by Ross Cyrus
    i have simple a form wich made by htmlHelper(mvc3) then inside of it i have 2 input field 1:type=text 2:type=submit to submit the form. there is no model behind.so i need to perfom a clientside validation on the textfield before submit it to the server.but i dont know how. i tried this puting manualy the 'data-* artibute , but does not work : @using( Html.BeginForm()) { <label for="UserName" >User Name</label> <div class="editor-field"> <input type="text" data-val="true" data-val-requierd="You must provide an user Name" id="userName" name="userName" placeholder="Enter Your User Name" /> </div> <input type="submit" value="Recover" /> } the "jquery.validate.min.js" and jquery.validate.unobtrusive.min.js and jquery.validate.min.js and jquery.validate.unobtrusive.min.js are loaded to the page. It doesnt let me to answer my self ,so i put it here : I solve it my self,just made an other view wich has its own model and Required on its propertyis and then just copy the renderd html to my own,and i got this and works : <input data-val="true" data-val-required="You must provide an user Name" id="UserName" name="UserName" type="text" value="" placeholder="Enter your User Name"/> <span class="field-validation-valid" data-valmsg-for="UserName" data-valmsg-replace="true"></span> And there is no type="Required".any way thank you guys.

    Read the article

  • Spring 3 MVC validation BindingResult doesn't contain any errors

    - by Travelsized
    I'm attempting to get a Spring 3.0.2 WebMVC project running with the new annotated validation support. I have a Hibernate entity annotated like this: @Entity @Table(name = "client") public class Client implements Serializable { private static final long serialVersionUID = 1L; @Id @Basic(optional = false) @Column(name = "clientId", nullable = false) @NotEmpty private Integer clientId; @Basic(optional = false) @Column(name = "firstname", nullable = false, length = 45) @NotEmpty @Size(min=2, max=45) private String firstname; ... more fields, getters and setters } I've turned on mvc annotation support in my applicationContext.xml file: <mvc:annotation-driven /> And I have a method in my controller that responds to a form submission: @RequestMapping(value="/addClient.htm") public String addClient(@ModelAttribute("client") @Valid Client client, BindingResult result) { if(result.hasErrors()) { return "addClient"; } service.storeClient(client); return "clientResult"; } When my app loads in the server, I can see in the server log file that it loads a validator: 15 [http-8084-2] INFO org.hibernate.validator.util.Version - Hibernate Validator 4.0.2.GA The problem I'm having is that the validator doesn't seem to kick in. I turned on the debugger, and when I get into the controller method, the BindingResult contains 0 errors after I submit an empty form. (The BindingResult does show that it contains the Client object as a target.) It then proceeds to insert a record without an Id and throws an exception. If I fill out an Id but leave the name blank, it creates a record with the Id and empty fields. What steps am I missing to get the validation working?

    Read the article

  • How can I unit test my custom validation attribute

    - by MightyAtom
    I have a custom asp.net mvc class validation attribute. My question is how can I unit test it? It would be one thing to test that the class has the attribute but this would not actually test that the logic inside it. This is what I want to test. [Serializable] [EligabilityStudentDebtsAttribute(ErrorMessage = "You must answer yes or no to all questions")] public class Eligability { [BooleanRequiredToBeTrue(ErrorMessage = "You must agree to the statements listed")] public bool StatementAgree { get; set; } [Required(ErrorMessage = "Please choose an option")] public bool? Income { get; set; } .....removed for brevity } [AttributeUsage(AttributeTargets.Class)] public class EligabilityStudentDebtsAttribute : ValidationAttribute { // If AnyDebts is true then // StudentDebts must be true or false public override bool IsValid(object value) { Eligability elig = (Eligability)value; bool ok = true; if (elig.AnyDebts == true) { if (elig.StudentDebts == null) { ok = false; } } return ok; } } I have tried to write a test as follows but this does not work: [TestMethod] public void Eligability_model_StudentDebts_is_required_if_AnyDebts_is_true() { // Arrange var eligability = new Eligability(); var controller = new ApplicationController(); // Act controller.ModelState.Clear(); controller.ValidateModel(eligability); var actionResult = controller.Section2(eligability,null,string.Empty); // Assert Assert.IsInstanceOfType(actionResult, typeof(ViewResult)); Assert.AreEqual(string.Empty, ((ViewResult)actionResult).ViewName); Assert.AreEqual(eligability, ((ViewResult)actionResult).ViewData.Model); Assert.IsFalse(((ViewResult)actionResult).ViewData.ModelState.IsValid); } The ModelStateDictionary does not contain the key for this custom attribute. It only contains the attributes for the standard validation attributes. Why is this? What is the best way to test these custom attributes? Thanks

    Read the article

  • Spring validation has error in XML document from ServletContext resource

    - by user1441404
    I applied spring validation in my registration page .but the follwing error are shown in my server log of my app engine server. javax.servlet.UnavailableException: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 22 in XML document from ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 30; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'property'. My code is given below : <?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd > <beans:bean name="/register" class="com.my.registration.NewUserRegistration"> <property name="validator"> <bean class="com.my.validation.UserValidator" /> </property> <beans:property name="formView" value="newuser"></beans:property> <beans:property name="successView" value="home"></beans:property> </beans:bean> <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> </beans:beans>

    Read the article

  • How to validate properties across Models without repeating the validation logic

    - by Mano
    Hello All, I am building a ASP.NET Mvc app. I have a Data model say User public class user { public int userId {get; private set}; public string FirstName {get; set;} } The validation to be done is that the firstname cannot exceed 50 characters. I have another presentation model in which i have the property FirstName too. I do not want to repeat the validation logic in both the models. I want to have it in one place and that should be it. I can do it in a simpler way by adding a function which can be called while setting the property like private string firstName; public string FirstName { get { return firstName; } set { if (PropertyValidator.ValidName(value)) // assuming ValidName exists and it will throw an exception if the value is not valid { firstName = value; } } } But I am looking for something much simpler so that I do not need to add this for every property I need to have it validated. I looked at ValidationAttribute but then again I can validate this only from a controller (ModelState.IsValid). Since this model could be used by some other type of apps like console app, I could not choose that. But if there is a way to use the Mvc's ModelState.IsValid from outside of a controller, that would be awesome. Any suggestions are greatly appreciated. Thanks!!

    Read the article

  • Entity Framework Validation & usage

    - by kmsellers
    I'm aware there is an AssociationChanged event, however, this event fires after the association is made. There is no AssociationChanging event. So, if I want to throw an exception for some validation reason, how do I do this and get back to my original value? Also, I would like to default values for my entity based on information from other entities but do this only when I know the entitiy is instanced for insertion into the database. How do I tell the difference between that and the object getting instanced because it is about to be populated based on existing data? Am I supposed to know? Is that considiered business logic that should be outside of my entity business logic? If that's the case, then should I be designing controller classes to wrap all these entities? My concern is that if I deliver back an entity, I want the client to get access to the properties, but I want to retain tight control over validations on how they are set, defaulted, etc. Every example I've seen references context, which is outside of my enity partial class validation, right? BTW, I looked at the EFPocoAdapter and for the life of me cannot determine how to populate lists of from within my POCO class... anyone know how I get to the context from a EFPoco Class?

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >