locked
Ability to force digit formatting for a Reservation Number. RRS feed

  • Question

  • Ability to force digit formatting for a Reservation Number. 

     number should be 8 digits and need to add validation to make sure the number can only be 8 digits.

    Wednesday, October 13, 2010 12:18 PM

Answers

  • Hi CRMAG

    You can use field level validation by applying javascript to the onChange event of the crm attribute which checks against a regular expression.
    I've regularly applied this for attributes such as bank details (Account number = 8 numerical digits) 

    //Regular Expression for, "8 Numerical digits only"
    var 8numFormat=/^\d{8}$/ 
    
    //Check For Data on entry 
    if (crmForm.all.new_Attributename.DataValue != null)
    	//if data exists, check it's format against the expression
    	{ 
    	if (crmForm.all.new_Attributename.DataValue.search(8numFormat)==-1)
    		//if it does not match, Alert the user and clear the data for re-input
    		{
    		alert("Please enter a valid number using 8 numerical digits");
    		crmForm.all.new_Attributename.DataValue = null
    		}
    	}
    
    Hope this helps, please let me know if you get any issues :)
    Craig


    Our company - XT BASE

    My LinkedIn
    • Proposed as answer by Craig Hamer Wednesday, October 13, 2010 2:27 PM
    • Marked as answer by CRMAG Wednesday, October 20, 2010 12:52 PM
    Wednesday, October 13, 2010 2:11 PM