Click here to Skip to main content
15,915,651 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 8:36
professionaljkirkerx18-Jul-18 8:36 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 8:51
indian14318-Jul-18 8:51 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 9:00
professionaljkirkerx18-Jul-18 9:00 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 9:06
indian14318-Jul-18 9:06 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 9:13
professionaljkirkerx18-Jul-18 9:13 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 10:23
indian14318-Jul-18 10:23 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 10:26
professionaljkirkerx18-Jul-18 10:26 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 12:38
indian14318-Jul-18 12:38 
Hi,

Yes I did in the below way
<script><br />
    if (1 == 1)
    {
        $('#idTxtForCode').addClass("allownumericwithoutdecimal");
    }

<pre>
$(".allownumericwithoutdecimal").on("keypress keyup blur", function (event)
{<br />
    $(this).val($(this).val().replace(/[^\d].+/, ""));

    if ((event.which < 48 || event.which > 57))
    {
        event.preventDefault();
    }        
});   



in the following form, it is working fine for the character values like its not inputting the character values when I type in, but when I enter one integer value it is working fine but when I enter second value, its removing all the values I entered making the textbox blank, I am not understanding why is it doing that way.
My form is as below:
@model XXXXX.Provider.Models.LookupTable

@{
    ViewBag.Title = "EditLookup";
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

<pre>
<div class="k-edit-form-container">
    <div class="editor-field" style="display:none;">
        @Html.Kendo().TextBoxFor(model => model.LookupTableId).HtmlAttributes(new { id = "idLookupTableId" })<br />
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Code)
    </div>
    <div class="editor-field">
        @Html.Kendo().TextBoxFor(model => model.Code).Name("txtForCode").HtmlAttributes(new { autocomplete = "off", id = "idTxtForCode" })            
        @*.HtmlAttributes(
        new { style = "width:250px", type = "text", size = "5", id = "txtLENum", required = "required", maxlength = "5", pattern = "[a-zA-z0-9]{5}", validationmessage = "Enter only 5 numerics for {0}" })*@
    </div>
    <div class="editor-label">
        @Html.LabelFor(model => model.Description)
    </div>
    <div class="editor-field">
        @Html.Kendo().TextBoxFor(model => model.Description).HtmlAttributes(new { autocomplete = "off" })
    </div>
    <div class="editor-label" style="display:none;">
        @Html.LabelFor(model => model.CreatedBy)
    </div>
    <div class="editor-field" style="display:none;">
        @Html.Kendo().TextBoxFor(model => model.CreatedBy)
    </div>
    <div class="editor-label" style="display:none;">
        @Html.LabelFor(model => model.CreatedDate)
    </div>
    <div class="editor-field" style="display:none;">
        @Html.Kendo().DatePickerFor(model => model.CreatedDate)
    </div>
    <div class="editor-label" style="display:none;">
        @Html.LabelFor(model => model.ModifiedBy)
    </div>
    <div class="editor-field" style="display:none;">
        @Html.Kendo().TextBoxFor(model => model.ModifiedBy)
    </div>
    <div class="editor-label" style="display:none;">
        @Html.LabelFor(model => model.ModifiedDate)
    </div>
    <div class="editor-field" style="display:none;">
        @Html.Kendo().DatePickerFor(model => model.ModifiedDate)
    </div>
    <div class="editor-label" style="display:none;">
        @Html.LabelFor(model => model.IsValid)
    </div>
    <div class="editor-field" style="display:none;">
        @Html.Kendo().CheckBoxFor(model => model.IsValid)
    </div>


}


And instead of doing the above function why is giving me error?
    $(".allownumericwithoutdecimal").on("keypress keyup blur", function (event)
    {      
        var charCode = (event.which) ? event.which : event.keyCode;
        if(charCode > 31 && (charCode < 48 || charCode > 57))
        {
            event.preventDefault();
        }
    }); 

Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."

-- modified 18-Jul-18 19:20pm.
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx18-Jul-18 13:12
professionaljkirkerx18-Jul-18 13:12 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14318-Jul-18 14:33
indian14318-Jul-18 14:33 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx19-Jul-18 7:09
professionaljkirkerx19-Jul-18 7:09 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14319-Jul-18 7:47
indian14319-Jul-18 7:47 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
jkirkerx19-Jul-18 8:46
professionaljkirkerx19-Jul-18 8:46 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14319-Jul-18 9:09
indian14319-Jul-18 9:09 
GeneralRe: Conditionally Loading Partial View in a Page using Javascript Pin
indian14319-Jul-18 11:21
indian14319-Jul-18 11:21 
Questiongetting these smtp exceptions in my mvc .net project,used different ports but still not workin ,can u plz help me? Pin
Member 1390903412-Jul-18 3:32
Member 1390903412-Jul-18 3:32 
AnswerRe: getting these smtp exceptions in my mvc .net project,used different ports but still not workin ,can u plz help me? Pin
F-ES Sitecore12-Jul-18 3:48
professionalF-ES Sitecore12-Jul-18 3:48 
AnswerRe: getting these smtp exceptions in my mvc .net project,used different ports but still not workin ,can u plz help me? Pin
jkirkerx18-Jul-18 13:14
professionaljkirkerx18-Jul-18 13:14 
QuestionDefault Download button is not working in Chrome browser Pin
Member 1370125111-Jul-18 19:54
Member 1370125111-Jul-18 19:54 
AnswerRe: Default Download button is not working in Chrome browser Pin
Richard Deeming12-Jul-18 1:03
mveRichard Deeming12-Jul-18 1:03 
Question.Net Core 2.1, Favicon.ico, robots.txt, sitemap.xml, google verification file Pin
jkirkerx8-Jul-18 12:26
professionaljkirkerx8-Jul-18 12:26 
AnswerRe: .Net Core 2.1, Favicon.ico, robots.txt, sitemap.xml, google verification file [solved] Pin
jkirkerx9-Jul-18 7:31
professionaljkirkerx9-Jul-18 7:31 
QuestionCouldn't retrieve all records from SQL database in c# Pin
Sehal6-Jul-18 23:12
Sehal6-Jul-18 23:12 
AnswerRe: Couldn't retrieve all records from SQL database in c# Pin
Mycroft Holmes7-Jul-18 13:44
professionalMycroft Holmes7-Jul-18 13:44 
SuggestionRe: Couldn't retrieve all records from SQL database in c# Pin
Richard Deeming9-Jul-18 8:43
mveRichard Deeming9-Jul-18 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.