This is a migrated thread and some comments may be shown as answers.

[Solved] numeric textbox validation not preventing submit

7 Answers 313 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Collier
Top achievements
Rank 1
Daniel Collier asked on 13 May 2010, 10:35 PM
I have a numeric textbox with some max and min validation on it.  If I enter a value that exceeds the max, it lets me type it, but when I tab to another control it highlights the textbox in red, which is cool.  However, it does not preventing submission of the form.  Am I missing something?  THis is the control

   <%= Html.Telerik().CurrencyTextBox() 
        .Name("cost") 
        .Spinners(false) 
        .MinValue(0) 
        .MaxValue((decimal)99999999.999999) 
        .Value( ViewData.Model.Cost)%><span class="requiredTag"> *</span><br /> 
We're using jquery validation using the jquery.validate.js api and we implement the validate method like so:

   <%Html.Telerik().ScriptRegistrar().Scripts(scripts => scripts.AddGroup("Validation", group => group.Add("~/Scripts/jquery.validate.js"))).OnDocumentReady(() => 
       {%> 
   $("#editform").validate( 
   {  
      rules:  
      {  
         name:  
         {  
             required: true  
         } 
//and so forth 

Does anyone have an idea what I'm doing wrong?

7 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 14 May 2010, 07:23 AM
Hi Daniel Collier,

It is hard to determine where could be the problem. I have attached a simple test project, which implements client-validation using jQuery validate.

Best wishes,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Daniel Collier
Top achievements
Rank 1
answered on 09 Jun 2010, 10:34 PM
Georgi, thanks for your reply.  I may not have been clear on my issue.  Your example seems to be demostrating required field validation, which works fine for us.  If a required telerik field is blank, then it prevents submission of the form.

My problem is when a value is present, but is beyond the maxvalue.  For example we have a percentage field and we set the min at 0 and max at 100.  Well as it stands now, I can enter 500 as a value and the telerik textbox will take it.  It highlights the box in red to complain, but when I click submit, the value saves anyway.  How do I keep the form from submitting when there is a max/min field violation?
0
Georgi Krustev
Telerik team
answered on 10 Jun 2010, 08:05 AM
Hello Daniel Collier,

You can achieve your goal using range attribute for validate the input value. For your convenience I have attached modified test project.

Kind regards,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Daniel Collier
Top achievements
Rank 1
answered on 10 Jun 2010, 03:28 PM
Thanks for the response.  I figured I could do it via jquery validation, but I was hoping not to have to duplicate the effort, meaning setting the telerik min and max AND the jquery ranges.

So just to confirm, the goal of the Telerik min and maxes is to mostly give immediate feedback if a range is out of bounds, but not actually prevent the submit?  I know it does sometimes prevent inputting a value out of range.  For example, if you set the min to zero, it will not allow you to type a dash for a negative number.

Thanks,

Dan
0
Georgi Krustev
Telerik team
answered on 10 Jun 2010, 03:58 PM
Hello Daniel Collier,

NumericTextBox component (Datepicker also) could not prevent submitting incorrect data. With this approach, you can use any validation tool, which you want and configure it in any way you want.
The main goal of min/max value is to give immediate UI notification.

Regards,
Georgi Krustev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Bob
Top achievements
Rank 1
answered on 08 Apr 2011, 04:55 PM
I think this is questionable. It should be configurable.

One step further, when the page is submitted and comes back, the old value suddenly appears again. So the value from before the clearing of the field. How can i prevent this?

Kind regards,
Bob Gladon
0
khaldoun
Top achievements
Rank 1
answered on 16 Jun 2011, 03:31 PM
There is a pb of Globalization with the numeric textbox,
If you go into frensh the decimal separtor is "," but with jquery It does not allaw me to write  12,45 it change it to 12,00
Am I missing something?
Tags
NumericTextBox
Asked by
Daniel Collier
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Daniel Collier
Top achievements
Rank 1
Bob
Top achievements
Rank 1
khaldoun
Top achievements
Rank 1
Share this question
or