Quantcast
Channel: Adobe Community : Unanswered Discussions - ColdFusion
Viewing all articles
Browse latest Browse all 5794

javascript error message

$
0
0

Hi. I have some javascript on my Add New Part page that has a form that says if a Part Number has a C and then a number behind it (like C1557), and the CN_Entry_Initials equal an "N", and the Validation_Qty is blank, make a Javascript error message display saying to enter a Validation Qty. I am trying to make this work on my Edit page also, but the error message does not display. I think it's because I have the input text box for the Part Number disabled. We don't want users to be able to update the part number once it's entered. If I just output the result of the Part Number, the javascript still doesn't work. How can I get the javascript to pop up an error message if the Part Number is C1557 (and the part number is just output to show the result), the CN_Entry_Initials equal an "N", and the Validation_Qty is blank? Below is the javascript I have and the form is below that. Thank you.

Andy

 

<SCRIPT LANGUAGE="JavaScript">

 

<!-- Begin

function verify() {

var PartNum=document.EditItem.Part_Number.value;

var regularExpression = new RegExp(/^[cC][0-9]/); //regular expression to check for a letter C followed by a number

 

if(regularExpression.test(PartNum)&& document.EditItem.CN_Entry_Initials.value == "N" && document.EditItem.Validation_Qty.value == "") { //this will return true if the input passes the regular expression

alert("Enter a Validation Quantity for this new Custom");

}

 

else

{

document.EditItem.submit();

}

 

}

//  End -->

</script>

 

 

<table width=900 cellpadding="0" cellspacing="4" border="0">

 

<cfform name="EditItem" method="post" action="edit_ec_number_action.cfm">

<CFOUTPUT QUERY="ShowItem" MAXROWS="1">

 

<tr>

<td class="edit" align="right">Change or new entry:</td>

<td>

 

 

<select name="CN_Entry_Initials">

   <option value="">Select</option>

   <cfloop query="ShowCNEntryInitials">

     <option value="#CN_Entry_Initials#"

<cfif #ShowCNEntryInitials.CN_Entry_Initials# EQ #ShowItem.CN_Entry#>selected</cfif>>#CN_Entry_Initials#

   </cfloop>

   </select>

</td>

 

<tr>

<td class="edit" align="right" valign="middle">Part Number:<br><h6>(Limit to 25 characters)</h6></td>

<td class="edit"><input type="hidden" name="#Part_Number#">#Part_Number#</td>

</tr>

 

<tr>

<td class="edit" align="right">Validation Quantity:</td>

<td>

<cfinput type="Text" name="Validation_Qty" size="12" value="#Trim(Validation_Qty)#" validate="integer">

</td>

</tr>

 

<tr>

<td>

<input type="button" value="Update"  onclick="verify();">

</td>

</tr>

 

</table>


Viewing all articles
Browse latest Browse all 5794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>