cancel
Showing results for 
Search instead for 
Did you mean: 

Error while trying to validate two input boxes at client side.

Former Member
0 Kudos

This is the code i am using to validate two input boxes.

I get an error in the IE which says: <b>'undefined is null or not an object'</b>

function validateInput(){

var noNull = validateNull();

var noNullTwo = validateNullTwo();

if(noNull==true)

{

}

else

{

alert("Enter values");

htmlbevent.cancelSubmit="true";

}

}

function validateNull(){

var startRange;

funcName = htmlb_formid + "_getHtmlbElementId";

func = window[funcName];

var temp1 = eval(func("range_Start"));

startRange = temp1.getValue();

if(startRange == '')

{

return false;

}

else

{

if(startRange.length < 😎

{

alert("Enter the value in proper format");

htmlbevent.cancelSubmit="true";

}

else

{

return true;

}

}

}

function validateNullTwo(){

var endRange;

funcName2 = htmlb_formid + "_getHtmlbElementId";

func2 = window[funcName2];

var temp2 = eval(func("range_End"));

endRange = temp2.getValue();

if(startRange == '')

{

return false;

}

else

{

if(endRange.length < 😎

{

alert("Enter the value in proper format");

htmlbevent.cancelSubmit="true";

}

else

{

return true;

}

}

}

</script>

<hbj:form id="myFormId" >

<hbj:textView id="title" text="Enter Sales Order Search Range" design="HEADER2"/><br><br>

<hbj:label id="lb_SearchStart" text="Start Range:" labelFor="range_Start" />

<hbj:inputField id="range_Start" jsObjectNeeded="true" type="string" required="true" maxlength="25"/>

<hbj:label id="lb_SearchEnd" text="End Range:" labelFor="range_End" />

<hbj:inputField id="range_End" type="string" maxlength="25"/><br><br>

<hbj:button id="submit" text="Search!" tooltip="Click me to Search" onClientClick="validateInput()" onClick="searchPressed" design="emphasized" />

</hbj:form>

</hbj:page>

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

There are two mistakes in your code.

1.You haven't defined the attribute jsObjectNeeded="true"

for inputField range_End.

Hence you are getting this error.

2.You are using start if(startRange == '') for checking blank value in the function validateNullTwo() but you have not defined the variable startRange in this function.

Regards,

Ajay

sridhar_k2
Active Contributor
0 Kudos

Hi Portal Newbie,

Please follow the below code. One i/p filed ,a button and a Java Script function.

In the function i searched with only null, if you want you can perform another function.

If you have any issues, please write me back.

<hbj:inputField

id="SystemId"

disabled="false"

type="string"

maxlength="60"

value=""

jsObjectNeeded="true" />

<hbj:button

id="Search"

text="Update"

width="125px"

tooltip=""

onClick="UpdateSystem"

onClientClick="validateFields()"

disabled="false"

design="EMPHASIZED"/>

<script language= "JavaScript" >

function validateFields(){

var funcName=htmlb_formid+"_getHtmlbElementId";

func=window[funcName];

var inputfield=eval(func("SystemId"));

var value=inputfield.getValue();

if(value=="")

alert("Please enter a value");

}

</script>

Thanks,

Sridhar