client-side-validation

Need Client Side Validation for TextBox if '<' and '>' are used in textbox ASP.NET

瘦欲@ 提交于 2019-12-12 01:52:57
问题 Could you please Suggest a client Side Validation for the TextBox in ASP.NET. Needs validation and should not allow user to use '<>'. When text is entered between '<' and '>', it should show validation 回答1: You can do this using CustomValidator <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:CustomValidator runat="server" id="customvalidator1" ControlToValidate="TextBox1" EnableClientScript="true" ErrorMessage="Cannot accept- < or >" ClientValidationFunction="jsvalidate" />

How to give validation in two textbox

落花浮王杯 提交于 2019-12-12 00:46:51
问题 I have a problem in this script. My function about given validation in two textbox. anybody here can help me? My function: <script> window.onload = function () { document.getElementById("pass").onchange = validatePassword; document.getElementById("rp_pass").onchange = validatePassword; }; function validatePassword() { var pass2=document.getElementById("pass").value; var pass1=document.getElementById("rp_pass").value; if(pass1!=pass2) document.getElementById("rp_pass").setCustomValidity(

Rails, Simple Form, and Client Side Validations aren't working

眉间皱痕 提交于 2019-12-12 00:25:46
问题 My model: class Hotel < ActiveRecord::Base attr_accessible :name belongs_to :user has_many :room_types validates :user_id, presence: true validates :name, presence: true, length: { in: 2..15 } end The form code: <%= simple_form_for @hotel, :validate => true do |f| %> <%= f.input :name %> <%= f.submit 'Create Hotel' , :class => 'btn btn-primary', :type => 'submit' %> <% end %> There doesn't seem to be any client side validation being performed. I can submit the form without filling in any

How to resolve an unexpected quantifier in Javascript regex pattern?

爷,独闯天下 提交于 2019-12-11 13:02:21
问题 Scenario: I've added a client side url validator using the following regex pattern. The pattern is supposed to check whether the URL input matches. ^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=

Customize Html.ValidationMessageFor doesn't work in client side

自作多情 提交于 2019-12-11 12:26:22
问题 I am working on mvc3 application, i have created a custom validationMessage to validate a simple field. This custom validationMessage only show an div with title and message instead of the default span, i have this : @Html.ValidationMessageCustomFor(model => model.FirstName) This is the code to my custom validation: public static MvcHtmlString ValidationCustomFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression) { string propertyName =

Primefaces clientValidator message not displayed

旧街凉风 提交于 2019-12-11 09:27:59
问题 I tried to use Primefaces <p:clientValidator> along with the <p:message> but without any success. The message is simply not displayed. Here is a snippet of my .xhtml: <h:form id="systemLogTable"> ... <h:panelGroup> <p:inputText id="last-input" value="#{lazyLogsDataModel.lastTime}" size="10" disabled="#{lazyLogsDataModel.timeFilteringOption != 2}"> <p:ajax event="keyup" update="logsTable" /> <p:clientValidator event="keyup" update="msg"/> </p:inputText> <h:selectOneMenu id="selectLastType"

Client side validation showing strange behavior on Bootstrap modal

安稳与你 提交于 2019-12-11 05:19:38
问题 I have a page which list all Countries in a tabular form and view has a model like below: public class CitySet { public IEnumerable<CityObject> Cities { get; set; } [Required] public string City { get; set; } [Required] public string CityCode { get; set; } } On the same page I have a link that allows the user to create a new Country via a modal popup(defined within that page) Modal Popup section of the page is shown below: @model CMS.Models.CitySet <div class="box-header well" data-original

Does ruby on rails have client side validation like ASP.NET MVC [duplicate]

痞子三分冷 提交于 2019-12-11 02:05:31
问题 This question already has answers here : Javascript validation using activerecord models validators (3 answers) Closed last year . In ASP.NET MVC you can setup client side validations with the data annotations model which is similar to validations in ruby on rails. However there are unobtrusive javascript hooks created that will automatically wire up client side validations on forms. Is there anything like this for Ruby on Rails? 回答1: I was wondering this just the other day, and I found this

How get AngularJS element by name?

老子叫甜甜 提交于 2019-12-10 13:33:41
问题 In my form validation there is part of server validations. So I should get back from the server list with the names of the fields and a string with the error in each of them. My idea was to write a general code knowledge to deal with all fields without knowing them in advance, by accessing them with their name. this is field for example: <!-- Email --> <div class="form-group" data-ng-class="{ 'has-error' : step1Form.email.$invalid && (!step1Form.email.$pristine || submitted) }"> <label>Email<

Make client-side and server-side validation rules the same

对着背影说爱祢 提交于 2019-12-09 22:18:58
问题 I have an application who use ASP.NET MVC and KnockoutJS for the MVVM part. The server bind the data to the server by JSON. The client treat data and make a standard POST callback after that. I have now to handle some business logic like : The property1 must be superior to 10 if property2 == "FOOBAR" The property2 must be != "" Etc etc... (there is a lot of conditions I have to handle) So, to make things simpler, is it possible to avoid code duplicate between the server side code (C#) and the