Prototype / Javascript Hints
Dec 03, 2008

Make sure a form element was selected.

 

<form>

<input type="text" name="foo" id="theid">

<input type="submit" name="submit" id="submit" value="submit">

</form>

 

<script>

if($F('theid')!='')

{

        $('submit').enable();

} else {

        $('submit').disable();

}

</script>

 

Put a little note of why the submit was disabled.

 

<div id="notice"></div>

<script>

if($F('theid')!='')

{

        $('notice').update('');

        $('submit').enable();

} else {

        $('notice').update('Please complete all the fields above.');

        $('submit').disable();

}

</script>

 

Put the cursor in the input field.

 

$('theid').focus();

 

 

 



Page 1 of 1

create discussion Create Discussion

Privacy Policy