Validate input field, display error on submit and stop dialog open if error

I have a problem trying to validate my input field and alert the error, if number is below 50, i would like to know how to display an error popup (alert, or what ever), but to stop opening dialog modal if error occurred.

I did a script to force users write numbers below 50 with:

    function handleChange(input) {
        if (input.value < 50) input.value = 50;
        if (input.value > 1000000) input.value = 1000000;

But once user type, for example: 23 and click on submit, it'll change the number in background to 50, but he would not be aware of that... What i can do about it?

Here's the full code i'm using:

<form id="testconfirmJQ" name="testconfirmJQ" method="post" onSubmit="return validator(users)" action="output.php">
    <select id="selectUsers" class=" outtaHere" name="users" onChange='Choice();'>
        <option value="0" selected="selected">Choose...</option>
        <option value="1">Test</option>

    <input type="hidden" id="ids" name="ids" >
    <input type="hidden" id="use" name="username" >
    <input type="hidden" id="ful" name="full_name" >

        How much?
        <input type="text" id="quantity" name="quantity" onchange="handleChange(this);">
        <div style="font-size: 12px; float: left;">*Minimum quantity: 50</div>
    <input id="submitJQ" name="submitJQ" type="submit" class="styled-button-1" value="Send" />

<div id="dialog" title="Potvrdite">
    <div class="scroll-content">
        <ul class="countrylist">
            <img src="./images/png.png" class="vizitke"/>

Thanks in advance...


function handleChange(input) 
    if (input.value < 50) 
       alert('your alert');
       input.value = 50;

     if (input.value > 1000000) 
       alert('your alert');
         input.value = 1000000;
     return false;

I this is what you are looking for

You can use this:

function handleChange(input) {
if (input.value < 50) {input.value = 50;alert("Your number is bellow 50!")}
if (input.value > 1000000) { input.value = 1000000;alert("Your number is above 1000000")}

Add an hidden input, whose default vale is false(means no error)

<input type="hidden" id="error" name="error" value='false'>

Then customize you js,

<script>function handleChange(input) {
if (input.value < 50) { input.value = 50; document.getElementById('error').value='true';}
if (input.value > 1000000) input.value = 1000000;}

function validator(user){

var error; error    =   document.getElementById('error').value; if(error == 'true'){alert('customize your alert error'); return false;} } </script>

Need Your Help

C# PowerShell pipeline input flag/property

c# powershell pipeline

I am creating PowerShell cmdlets in C# by extending the PSCmdlet class.

Reference Key Error in Transaction Scope Using Entity Framework

linq entity-framework transactions

I am Using Transaction Scope for Performing the Insert In Multiple Tables using Try and Catch. But when i am Getting the Error Within Transaction Scope it's not allowing me to Save the Data in catch

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.