Jump to content
  • 0

Data Validation Question


csporcic

Question

I'm looking for help with a script I have created to validate a field. The purpose of the script is to limit the maximum entry of a numeric text entry field based on a cascading dropdown which includes the maximum value for a particular product. The user selects the product from the dropdown, then enters the quantity they want to order. This quantity is limited by the product they select. Here is the script that has been placed in the footer of the datapage. The first part of the script populates text field Virtual3 with the value of the cascading dropdown field Virtual2. This script works fine. The second part of the script attempts to validate the entry in text field Qty with the limit established by Virtual3. This script is not working and only avoids the Alert message when Qty = Virtual3, not when Qty is less than Virtual3. Please review and let me know if you have any suggestions. 

<script> function drop(){ document.getElementById('cbParamVirtual3').value = document.getElementsByName('cbParamVirtual2')[0].value; } document.getElementsByName('cbParamVirtual2')[0].onchange = drop; </script>
<script type="text/javascript"> function ValidateNumbers() { var max=document.getElementById('cbParamVirtual3').value; var qty=document.getElementById('InsertRecordQty').value; if(qty<1||qty>max) { alert("The pieces ordered cannot exceed the maximum quantity."); return true; } } document.getElementById('Submit').onclick = function() { if (!ValidateNumbers()) { this.submit(); } else { return false; } } </script>

 Thanks, Chris

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hi,

I am making a simple registration form.

which contain the field First name, last name,email address,mobile no.

I want to validate all field like below

First / Last name :- Only alpha-bates are allowed

email Address :- authenticate email allow

mobile no.:- only digit allowed

please sent me solution ASAP

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...