on 2006 Jan 05 10:43 AM
Hi,
I am trying to use the invalid property of an input field (in javascript) to decide whether to post a form to the server. My elements are:
<hbj:form id="myFormId"
method="post"
encodingType="multipart/form-data">
<hbj:inputField
id="datefield"
type="DATE"
maxlength="10"
design="STANDARD"
jsObjectNeeded="true"
showHelp="TRUE">
</hbj:inputField>
<hbj:button
id="go"
text="Go"
onClientClick="if(!CheckDate(this))htmlbevent.cancelSubmit=true;"
onClick="go">
</hbj:button>
</hbj:form>
And then I have my javascipt validation:
function getElement(id){
return document.getElementById(
eval(htmlb_formid + "_htmlbElements['"id"'];"));
}
function getElementState(id){
return document.getElementById(
eval(htmlb_formid + "_htmlbElements['"id"'].isvalid;"));
}
function getValueOfElement(id){
var value = parseFloat(getElement(id).value);
return isNaN(value)?0:value;
}
function getStatusOfElement(id){
var val1 = parseFloat(getElement(id).valid);
var val1 = getElement(id).value;
var val2 = getElement(id).isvalid;
var val3 = getElement(id).invalid;
if (val1 == 0){
return 0;
}
else{
return(val1 + " " + val2 + " " + val3);
}
}
function CheckDate(PageTitle1){
var myEl2 = getValueOfElement('datefield');
alert(myEl2);
var myEl3 = getStatusOfElement('datefield');
alert(myEl3);
var myEl5 = getElementState('datefield');
alert(myEl5);
var myEl4 = getElement('datefield').type;
alert(myEl4);
}
-
I know its a bit mashed together there but the getStatusOfElement should be able to see if the invalid property is true or not.
Please help??
Logically what I want to do is say: if the invalid property for the textbox is true then don't submit the form to the server.
Hi,
change the code to
if (!CheckDate(val1)) {
not
if (!CheckDate(var)) {
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.